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.
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;
{
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.pipelineConfiguration =
;
desc.captureTextureFrequency = 10;
desc.ignoreRegistrationErrors = false;
Processing 3D Data
When processing, you must launch algorithms in the exact order given in General Pipeline.
To start an algorithm, do the following:
- Run std::swap to put the previous algorithm's output to the input of the next one
- Clear the new
workset.out
(which is actually the former input)
- Initialize the default algorithm's settings, alter them as necessary
- createXxxxAlgorithm() using the obtained parameters' values
- Run executeJob()
Running Algorithm
std::wcout << L"Creating fast fusion procedure..." << std::endl;
TRef<asdk::IAlgorithm> fusion;
asdk::FastFusionSettings fusionDesc;
fusionDesc.resolution = 2.f;
std::wcout << L"OK" << std::endl;
std::wcout << L"Launching the fast fusion algorithm..." << std::endl;
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:
{
std::wcout << L"Creating serial registration procedure..." << std::endl;
TRef<asdk::IAlgorithm> serialRegistration;
asdk::SerialRegistrationSettings 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()).
{
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";
{
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.