Artec 3D Scanning SDK  2.0
Basics

To get familiar with API, study the sections below.

For more details, consult scanning-and-process-sample.cpp. The figure below shows the simplified procedure designed to obtain a complete 3D model and store it on the disk.

pipeline.svg
How to scan and process data using the SDK

Creating Scanner Object

If you connected only one scanner, you can get right to the createScanner() function.

std::wcout << L"Looking for scanner..." << std::endl;
TRef<asdk::IScanner> scanner;
asdk::ErrorCode ec = asdk::createScanner( &scanner, NULL );
if( ec != asdk::ErrorCode_OK )
{
std::wcout << L"No scanners found" << std::endl;
return ec;
}
std::wcout << L"OK" << std::endl;
std::wcout << L"Found scanner with serial number " << scanner->getId()->serial << std::endl;

Scanning Procedure

Scanning procedure is an algorithm that captures, reconstructs, registers and saves frames into the special storage units called IModel. For the most common usage scenarios, employing scanning procedure is the best choice. You can configure additional options (see Tweaking Scan Settings) before you createScanningProcedure.

std::wcout << L"Creating scanning procedure..." << std::endl;
TRef<asdk::IScanningProcedure> scanning;
asdk::ScanningProcedureSettings desc = { 0 };
desc.maxFrameCount = NumberOfFramesToCapture;
desc.initialState = asdk::ScanningState_Record;
desc.pipelineConfiguration =
;
desc.captureTextureFrequency = 10;
desc.ignoreRegistrationErrors = false;
SAFE_SDK_CALL( asdk::createScanningProcedure( &scanning, scanner, &desc ) );

Processing 3D Data

When processing, you must launch algorithms in the exact order given in General Pipeline.

To start an algorithm, do the following:

  1. Run std::swap to put the previous algorithm's output to the input of the next one
  2. Clear the new workset.out (which is actually the former input)
  3. Initialize the default algorithm's settings, alter them as necessary
  4. createXxxxAlgorithm() using the obtained parameters' values
  5. Run executeJob()

Running Algorithm

std::wcout << L"Creating fast fusion procedure..." << std::endl;
TRef<asdk::IAlgorithm> fusion;
asdk::FastFusionSettings fusionDesc;
// get default settings
SAFE_SDK_CALL( asdk::initializeFastFusionSettings( &fusionDesc, scannerType ) );
fusionDesc.resolution = 2.f;
SAFE_SDK_CALL( asdk::createFastFusionAlgorithm( &fusion, &fusionDesc ) );
std::wcout << L"OK" << std::endl;
std::wcout << L"Launching the fast fusion algorithm..." << std::endl;
SAFE_SDK_CALL( asdk::executeJob( fusion, &workset ) );
std::wcout << L"OK" << std::endl;

Some algorithms may have a few settings. In that case, use the following code snippet to pass values to the algorithm:

// get scanner type from the very first scan in workset
asdk::ScannerType scannerType = (asdk::ScannerType)workset.in->getElement(0)->getScannerType();
// apply serial registration
{
std::wcout << L"Creating serial registration procedure..." << std::endl;
TRef<asdk::IAlgorithm> serialRegistration;
asdk::SerialRegistrationSettings serialDesc = {
};
SAFE_SDK_CALL( asdk::createSerialRegistrationAlgorithm( &serialRegistration, &serialDesc ) );
std::wcout << L"OK" << std::endl;

Workset

Workset is a pointer to the input/output object that mirrors the IModel structure.

Saving 3D Model

To save a complete 3D model, retrieve data from the ICompositeMesh object. The code snipped below shows how to save a polygonal model in the OBJ format. It uses saveObjCompositeToFile(); the other functions and formates related to storing and loading are listed in artec::sdk::base::io.

Precondition
Before you can proceed with saving, you must successfully scan data, register and optimize them (createSerialRegistrationAlgorithm() and createGlobalRegistrationAlgorithm()) and produce a model (createFastFusionAlgorithm()).
// saving the resulting mesh to OBJ format
{
asdk::ICompositeContainer* meshContainer = workset.in->getCompositeContainer();
if( meshContainer && meshContainer->getSize() > 0 )
{
asdk::ICompositeMesh* resultMesh = meshContainer->getElement( 0 );
std::wcout << L"Saving the resulting mesh to an OBJ file..." << std::endl;
const wchar_t* filename = OUTPUT_DIR L"\\untextured-mesh.obj";
asdk::ErrorCode ec = asdk::io::saveObjCompositeToFile( filename, resultMesh );
if( ec != asdk::ErrorCode_OK )
{
std::wcout << L"Cannot open file '" << filename << L"'" << std::endl;
std::wcout << L"skipped" << std::endl;
}
else
{
std::wcout << L"OK" << std::endl;
}
}
}

Starting from the SDK version 2.0, you can save data to Artec Studio projects. See Saving to Project and project-sample.cpp for details.