本文整理汇总了C++中qcar::TargetFinder::enableTracking方法的典型用法代码示例。如果您正苦于以下问题:C++ TargetFinder::enableTracking方法的具体用法?C++ TargetFinder::enableTracking怎么用?C++ TargetFinder::enableTracking使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qcar::TargetFinder
的用法示例。
在下文中一共展示了TargetFinder::enableTracking方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QCAR_onUpdate
virtual void QCAR_onUpdate(QCAR::State& state)
{
// Get the tracker manager:
QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance();
// Get the image tracker:
QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>(
trackerManager.getTracker(QCAR::Tracker::IMAGE_TRACKER));
// Get the target finder:
QCAR::TargetFinder* finder = imageTracker->getTargetFinder();
// Check if there are new results available:
const int statusCode = finder->updateSearchResults();
// Show a message if we encountered an error:
if (statusCode < 0)
{
showErrorMessage(statusCode, state.getFrame().getTimeStamp());
}
else if (statusCode == QCAR::TargetFinder::UPDATE_RESULTS_AVAILABLE)
{
// Process new search results
if (finder->getResultCount() > 0)
{
const QCAR::TargetSearchResult* result = finder->getResult(0);
// Check if this target is suitable for tracking:
if (result->getTrackingRating() > 0)
{
// Create a new Trackable from the result:
QCAR::Trackable* newTrackable = finder->enableTracking(*result);
if (newTrackable != 0)
{
LOG("Successfully created new trackable '%s' with rating '%d'.",
newTrackable->getName(), result->getTrackingRating());
// Checks if the targets has changed
LOG( "Comparing Strings. currentTargetId: %s lastTargetId: %s",
result->getUniqueTargetId(), lastTargetId);
if (strcmp(result->getUniqueTargetId(), lastTargetId) != 0)
{
// If the target has changed then regenerate the texture
// Cleaning this value indicates that the product Texture needs to be generated
// again in Java with the new Book data for the new target
deleteCurrentProductTexture = true;
// Starts the loading state for the product
renderState = RS_LOADING;
// Copies the new target Metadata
snprintf(targetMetadata, CONTENT_MAX, "%s", result->getMetaData());
// Calls the Java method with the current product texture
createProductTexture(targetMetadata);
}
else
renderState = RS_NORMAL;
// Initialize the frames to skip variable, used for waiting
// a few frames for getting the chance to tracking before
// starting the transition to 2D when there is no target
pthread_mutex_lock(&framesToSkipMutex);
framesToSkipBeforeRenderingTransition = 10;
pthread_mutex_unlock(&framesToSkipMutex);
// Initialize state variables
showAnimation3Dto2D = true;
trackingStarted = false;
// Updates the value of the current Target Id with the new target found
pthread_mutex_lock(&lastTargetIdMutex);
strcpy(lastTargetId, result->getUniqueTargetId());
pthread_mutex_unlock(&lastTargetIdMutex);
enterContentMode();
}
else
LOG("Failed to create new trackable.");
}
}
}
}
示例2: QCAR_onUpdate
virtual void QCAR_onUpdate(QCAR::State&) {
if (dataSetToActivate != NULL) {
QCAR::TrackerManager& trackerManager =
QCAR::TrackerManager::getInstance();
QCAR::ImageTracker* imageTracker =
static_cast<QCAR::ImageTracker*>(trackerManager.getTracker(
QCAR::ImageTracker::getClassType()));
if (imageTracker == 0) {
LOG("Failed to activate data set.");
return;
}
imageTracker->activateDataSet(dataSetToActivate);
if(isExtendedTrackingActivated)
{
for (int tIdx = 0; tIdx < dataSetToActivate->getNumTrackables(); tIdx++)
{
QCAR::Trackable* trackable = dataSetToActivate->getTrackable(tIdx);
trackable->startExtendedTracking();
}
}
dataSetToActivate = NULL;
}
if (scanningMode) {
QCAR::TrackerManager& trackerManager =
QCAR::TrackerManager::getInstance();
QCAR::ImageTracker* imageTracker =
static_cast<QCAR::ImageTracker*>(trackerManager.getTracker(
QCAR::ImageTracker::getClassType()));
// Get the target finder:
QCAR::TargetFinder* targetFinder = imageTracker->getTargetFinder();
// Check if there are new results available:
const int statusCode = targetFinder->updateSearchResults();
if (statusCode < 0) {
char errorMessage[80];
LOG(errorMessage, "Error with status code %d", statusCode);
} else if (statusCode
== QCAR::TargetFinder::UPDATE_RESULTS_AVAILABLE) {
// Process new search results
if (targetFinder->getResultCount() > 0) {
const QCAR::TargetSearchResult* result =
targetFinder->getResult(0);
// Check if this target is suitable for tracking:
if (result->getTrackingRating() > 0) {
// Create a new Trackable from the result:
QCAR::Trackable* newTrackable =
targetFinder->enableTracking(*result);
if (newTrackable != 0) {
LOG(
"Successfully created new trackable '%s' with rating '%d'.",
newTrackable->getName(), result->getTrackingRating());
if (strcmp(result->getUniqueTargetId(),
lastTargetId) != 0) {
// Copies the new target Metadata
snprintf(targetMetadata, CONTENT_MAX, "%s",
result->getMetaData());
//LOG(targetMetadata);
}
strcpy(lastTargetId, result->getUniqueTargetId());
// Stop Cloud Reco scanning
targetFinder->stop();
scanningMode = false;
}
}
}
}
}
}