本文整理汇总了C++中qcar::TargetFinder类的典型用法代码示例。如果您正苦于以下问题:C++ TargetFinder类的具体用法?C++ TargetFinder怎么用?C++ TargetFinder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TargetFinder类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: configureVideoBackground
// ----------------------------------------------------------------------------
// Starts the Camera
// ----------------------------------------------------------------------------
JNIEXPORT void JNICALL
Java_com_qualcomm_QCARSamples_CloudRecognition_CloudReco_startCamera(JNIEnv *, jobject)
{
// Initialize the camera:
if (!QCAR::CameraDevice::getInstance().init())
return;
// Configure the video background
configureVideoBackground();
// Select the default mode:
if (!QCAR::CameraDevice::getInstance().selectVideoMode(
QCAR::CameraDevice::MODE_DEFAULT))
return;
// Start the camera:
if (!QCAR::CameraDevice::getInstance().start())
return;
// Start the tracker:
QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance();
QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>(
trackerManager.getTracker(QCAR::Tracker::IMAGE_TRACKER));
assert(imageTracker != 0);
imageTracker->start();
// Start cloud based recognition if we are in scanning mode:
if(scanningMode)
{
QCAR::TargetFinder* targetFinder = imageTracker->getTargetFinder();
assert (targetFinder != 0);
crStarted = targetFinder->startRecognition();
}
}
示例2: assert
// ----------------------------------------------------------------------------
// Enables CloudReco Service
// ----------------------------------------------------------------------------
JNIEXPORT void JNICALL
Java_com_qualcomm_QCARSamples_CloudRecognition_CloudReco_enterScanningModeNative(JNIEnv*, jobject)
{
QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance();
QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>(
trackerManager.getTracker(QCAR::Tracker::IMAGE_TRACKER));
assert(imageTracker != 0);
QCAR::TargetFinder* targetFinder = imageTracker->getTargetFinder();
assert (targetFinder != 0);
// Start CloudReco
crStarted = targetFinder->startRecognition();
// Clear all trackables created previously:
targetFinder->clearTrackables();
scanningMode = true;
// Updates state variables
showAnimation3Dto2D = false;
showAnimation2Dto3D = false;
isShowing2DOverlay = false;
renderState = RS_SCANNING;
}
示例3: LOG
// ----------------------------------------------------------------------------
// Initialize Cloud Reco
// ----------------------------------------------------------------------------
JNIEXPORT int JNICALL
Java_com_qualcomm_QCARSamples_CloudRecognition_CloudReco_initCloudReco(JNIEnv *, jobject)
{
LOG("Java_com_qualcomm_QCARSamples_VisualSearch_VisualSearch_initVisualSearch");
// Get the image tracker:
QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance();
QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>(
trackerManager.getTracker(QCAR::Tracker::IMAGE_TRACKER));
assert(imageTracker != NULL);
// Initialize visual search:
QCAR::TargetFinder* targetFinder = imageTracker->getTargetFinder();
assert(targetFinder != NULL);
// Start initialization:
if (targetFinder->startInit(kAccessKey, kSecretKey))
{
targetFinder->waitUntilInitFinished();
}
int resultCode = targetFinder->getInitState();
if ( resultCode != QCAR::TargetFinder::INIT_SUCCESS)
{
LOG("Failed to initialize target finder.");
return resultCode;
}
// Use the following calls if you would like to customize the color of the UI
// targetFinder->setUIScanlineColor(1.0, 0.0, 0.0);
// targetFinder->setUIPointColor(0.0, 0.0, 1.0);
return resultCode;
}
示例4:
JNIEXPORT void JNICALL
Java_rajawali_vuforia_RajawaliVuforiaActivity_stopCamera(JNIEnv *, jobject) {
LOG("Java_rajawali_vuforia_RajawaliVuforiaActivity_stopCamera");
// Stop the tracker:
QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance();
QCAR::Tracker* markerTracker = trackerManager.getTracker(
QCAR::MarkerTracker::getClassType());
if (markerTracker != 0)
markerTracker->stop();
QCAR::ImageTracker* imageTracker =
static_cast<QCAR::ImageTracker*>(trackerManager.getTracker(
QCAR::ImageTracker::getClassType()));
if (imageTracker != 0)
imageTracker->stop();
QCAR::CameraDevice::getInstance().stop();
// Stop Cloud Reco:
QCAR::TargetFinder* targetFinder = imageTracker->getTargetFinder();
assert(targetFinder != 0);
targetFinder->stop();
// Clears the trackables
targetFinder->clearTrackables();
QCAR::CameraDevice::getInstance().deinit();
initStateVariables();
}
示例5: glClear
//.........这里部分代码省略.........
deleteCurrentProductTexture = false;
}
// If the render state indicates that the texture is generated it generates
// the OpenGL texture for start drawing the plane with the book data
if (renderState == RS_TEXTURE_GENERATED)
{
generateProductTextureInOpenGL();
}
// Did we find any trackables this frame?
if (state.getNumTrackableResults() > 0)
{
trackingStarted = true;
// If we are already tracking something we don't need
// to wait any frame before starting the 2D transition
// when the target gets lost
pthread_mutex_lock(&framesToSkipMutex);
framesToSkipBeforeRenderingTransition = 0;
pthread_mutex_unlock(&framesToSkipMutex);
// Gets current trackable result
const QCAR::TrackableResult* trackableResult = state.getTrackableResult(0);
if (trackableResult == NULL)
{
return;
}
modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(trackableResult->getPose());
// Get the size of the ImageTarget
QCAR::ImageTargetResult *imageResult = (QCAR::ImageTargetResult *)trackableResult;
targetSize = imageResult->getTrackable().getSize();
// Renders the Augmentation View with the 3D Book data Panel
renderAugmentation(trackableResult);
}
else
{
// Manages the 3D to 2D Transition initialization
if (!scanningMode && showAnimation3Dto2D && renderState == RS_NORMAL
&& framesToSkipBeforeRenderingTransition == 0)
{
startTransitionTo2D();
}
// Reduces the number of frames to wait before triggering
// the transition by 1
if( framesToSkipBeforeRenderingTransition > 0 && renderState == RS_NORMAL)
{
pthread_mutex_lock(&framesToSkipMutex);
framesToSkipBeforeRenderingTransition -= 1;
pthread_mutex_unlock(&framesToSkipMutex);
}
}
// Logic for rendering Transition to 2D
if (renderState == RS_TRANSITION_TO_2D && showAnimation3Dto2D)
{
renderTransitionTo2D();
}
// Logic for rendering Transition to 3D
if (renderState == RS_TRANSITION_TO_3D )
{
renderTransitionTo3D();
}
// 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();
// Renders the current state - User process Feedback
if (finder->isRequesting())
{
// Requesting State - Show Requesting text in Status Bar
setStatusBarText("Requesting");
showStatusBar();
}
else
{
// Hiding Status Bar
hideStatusBar();
}
glDisable(GL_DEPTH_TEST);
QCAR::Renderer::getInstance().end();
}
示例6: 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.");
}
}
}
}
示例7: 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;
}
}
}
}
}
}