本文整理汇总了C++中qcar::State::getFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ State::getFrame方法的具体用法?C++ State::getFrame怎么用?C++ State::getFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qcar::State
的用法示例。
在下文中一共展示了State::getFrame方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QCAR_onUpdate
virtual void QCAR_onUpdate(QCAR::State& state)
{
//from
//https://developer.vuforia.com/forum/faq/android-how-can-i-access-camera-image
QCAR::Image *imageRGB565 = NULL;
QCAR::Frame frame = state.getFrame();
for (int i = 0; i < frame.getNumImages(); ++i) {
const QCAR::Image *image = frame.getImage(i);
if (image->getFormat() == QCAR::RGB565) {
imageRGB565 = (QCAR::Image*)image;
break;
}
}
if (imageRGB565) {
JNIEnv* env = 0;
if ((javaVM != 0) && (activityObj != 0) && (javaVM->GetEnv((void**)&env, JNI_VERSION_1_4) == JNI_OK)) {
const short* pixels = (const short*) imageRGB565->getPixels();
int width = imageRGB565->getWidth();
int height = imageRGB565->getHeight();
int numPixels = width * height;
// LOG("Update video image...");
jbyteArray pixelArray = env->NewByteArray(numPixels * 2);
env->SetByteArrayRegion(pixelArray, 0, numPixels * 2, (const jbyte*) pixels);
jclass javaClass = env->GetObjectClass(activityObj);
jmethodID method = env-> GetMethodID(javaClass, "setRGB565CameraImage", "([BII)V");
env->CallVoidMethod(activityObj, method, pixelArray, width, height);
env->DeleteLocalRef(pixelArray);
}
}
}
示例2: 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.");
}
}
}
}