FileCaptureInterface::FramePair FileCaptureInterface::getFrame() { FramePair result; string name0 = getImageFileName(mCount, 0); string name1 = getImageFileName(mCount, 1); if (mVerbose) { printf("Grabbing frame from file: %s\n", name0.c_str()); } result.bufferLeft = BufferFactory::getInstance()->loadG12Bitmap(name0); if (result.bufferLeft) { if (mVerbose) { printf("Grabbing frame from file: %s\n", name1.c_str()); } result.bufferRight = BufferFactory::getInstance()->loadG12Bitmap(name1); } if (!result.bufferLeft || !result.bufferRight) { result.freeBuffers(); if (mVerbose) { printf("File not found, resetting to first image in the sequence.\n"); } resetImageFileCounter(); return getFrame(); } increaseImageFileCounter(); return result; }
FileCaptureInterface::FramePair FileCaptureInterface::getFrame() { FramePair result; string name0 = getImageFileName(mCount, 0); string name1 = getImageFileName(mCount, 1); mVerbose = true; if (mVerbose) { printf("Grabbing frame from file: %s (%s)\n" , name0.c_str() , mIsRgb ? "rgb" : "gray"); } if (mIsRgb) { result.rgbBufferLeft = BufferFactory::getInstance()->loadRGB24Bitmap(name0); result.bufferLeft = result.rgbBufferLeft->toG12Buffer(); result.rgbBufferRight = BufferFactory::getInstance()->loadRGB24Bitmap(name1); result.bufferRight = result.rgbBufferRight->toG12Buffer(); } else { result.bufferLeft = BufferFactory::getInstance()->loadG12Bitmap(name0); result.bufferRight = BufferFactory::getInstance()->loadG12Bitmap(name1); } /* if (result.bufferLeft) { if (mVerbose) { printf("Grabbing frame from file: %s\n", name1.c_str()); } result.bufferRight = BufferFactory::getInstance()->loadG12Bitmap(name1); }*/ if (result.bufferLeft == NULL && result.bufferRight == NULL) { result.freeBuffers(); if (mVerbose) { printf("Files not found, resetting to first image in the sequence.\n"); } resetImageFileCounter(); return getFrame(); } increaseImageFileCounter(); return result; }
V4L2CaptureInterface::FramePair V4L2CaptureInterface::getFrameRGB24() { CaptureStatistics stats; PreciseTimer start = PreciseTimer::currentTime(); protectFrame.lock(); FramePair result; RGB24Buffer **results[MAX_INPUTS_NUMBER] = { &result.buffers[LEFT_FRAME ].rgbBuffer, &result.buffers[RIGHT_FRAME ].rgbBuffer, &result.buffers[THIRD_FRAME ].rgbBuffer, &result.buffers[FOURTH_FRAME].rgbBuffer }; for (int i = 0; i < MAX_INPUTS_NUMBER; i++) { decodeDataRGB24(&camera[i], ¤tFrame[i], results[i]); if ((*results[i]) == NULL) { printf("V4L2CaptureInterface::getFrameRGB24(): Precrash condition at %d (%s)\n", i, getFrameSourceName((FrameSourceId)i)); } } if (result.rgbBufferLeft() != NULL) { result.setBufferLeft ( result.rgbBufferLeft() ->toG12Buffer() ); // FIXME } if (result.rgbBufferRight() != NULL) { result.setBufferRight ( result.rgbBufferRight()->toG12Buffer() ); } if (currentFrame[LEFT_FRAME].isFilled) result.setTimeStampLeft (currentFrame[LEFT_FRAME].usecsTimeStamp()); if (currentFrame[RIGHT_FRAME].isFilled) result.setTimeStampRight (currentFrame[RIGHT_FRAME].usecsTimeStamp()); if (skippedCount == 0) { // SYNC_PRINT(("Warning: Requested same frames twice. Is this by design?\n")); } stats.framesSkipped = skippedCount > 0 ? skippedCount - 1 : 0; skippedCount = 0; protectFrame.unlock(); stats.values[CaptureStatistics::DECODING_TIME] = start.usecsToNow(); stats.values[CaptureStatistics::INTERFRAME_DELAY] = frameDelay; int64_t desync = currentFrame[LEFT_FRAME ].usecsTimeStamp() - currentFrame[RIGHT_FRAME].usecsTimeStamp(); stats.values[CaptureStatistics::DESYNC_TIME] = CORE_ABS(desync); stats.values[CaptureStatistics::DATA_SIZE] = currentFrame[LEFT_FRAME].bytesused; if (imageInterfaceReceiver != NULL) { imageInterfaceReceiver->newStatisticsReadyCallback(stats); } else { SYNC_PRINT(("Warning: V4L2CaptureInterface::getFrameRGB24(): imageInterfaceReceiver is NULL\n")); } return result; }
V4L2CaptureInterface::FramePair V4L2CaptureInterface::getFrame() { // SYNC_PRINT(("V4L2CaptureInterface::getFrame(): called\n")); CaptureStatistics stats; PreciseTimer start = PreciseTimer::currentTime(); FramePair result; protectFrame.lock(); G12Buffer **results[MAX_INPUTS_NUMBER] = { &result.buffers[LEFT_FRAME ].g12Buffer, &result.buffers[RIGHT_FRAME].g12Buffer, &result.buffers[LEFT_FRAME ].g12Buffer, &result.buffers[RIGHT_FRAME].g12Buffer, }; result.setRgbBufferRight(NULL); result.setRgbBufferLeft (NULL); //SYNC_PRINT(("LF:%s RF:%s\n", // currentFrame[Frames::LEFT_FRAME ].isFilled ? "filled" : "empty" , // currentFrame[Frames::RIGHT_FRAME].isFilled ? "filled" : "empty")); for (int i = 0; i < MAX_INPUTS_NUMBER; i++) { decodeData(&camera[i], ¤tFrame[i], results[i]); if ((*results[i]) == NULL) { SYNC_PRINT(("V4L2CaptureInterface::getFrame(): Precrash condition\n")); } } if (currentFrame[LEFT_FRAME].isFilled) result.setTimeStampLeft (currentFrame[LEFT_FRAME].usecsTimeStamp()); if (currentFrame[RIGHT_FRAME].isFilled) result.setTimeStampRight (currentFrame[RIGHT_FRAME].usecsTimeStamp()); if (skippedCount == 0) { //SYNC_PRINT(("Warning: Requested same frames twice. Is this by design?\n")); } stats.framesSkipped = skippedCount > 0 ? skippedCount - 1 : 0; skippedCount = 0; protectFrame.unlock(); stats.values[CaptureStatistics::DECODING_TIME] = start.usecsToNow(); stats.values[CaptureStatistics::INTERFRAME_DELAY] = frameDelay; int64_t desync = currentFrame[LEFT_FRAME].usecsTimeStamp() - currentFrame[RIGHT_FRAME].usecsTimeStamp(); stats.values[CaptureStatistics::DESYNC_TIME] = desync > 0 ? desync : -desync; stats.values[CaptureStatistics::DATA_SIZE] = currentFrame[LEFT_FRAME].bytesused; if (imageInterfaceReceiver != NULL) { imageInterfaceReceiver->newStatisticsReadyCallback(stats); } return result; }