INT UEyeCamDriver::setStandbyMode() { if (!isConnected()) return IS_INVALID_CAMERA_HANDLE; INT is_err = IS_SUCCESS; if (extTriggerModeActive()) { if ((is_err = is_DisableEvent(cam_handle_, IS_SET_EVENT_FRAME)) != IS_SUCCESS) { std::cerr << "Could not disable frame event for UEye camera '" << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl; return is_err; } if ((is_err = is_SetExternalTrigger(cam_handle_, IS_SET_TRIGGER_OFF)) != IS_SUCCESS) { std::cerr << "Could not disable external trigger mode on UEye camera '" << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl; return is_err; } is_SetExternalTrigger(cam_handle_, IS_GET_TRIGGER_STATUS); // documentation seems to suggest that this is needed to disable external trigger mode (to go into free-run mode) if ((is_err = is_StopLiveVideo(cam_handle_, IS_WAIT)) != IS_SUCCESS) { std::cerr << "Could not stop live video mode on UEye camera '" << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl; return is_err; } std::cout << "Stopped external trigger mode on UEye camera '" + cam_name_ + "'" << std::endl; } else if (freeRunModeActive()) { UINT nMode = IO_FLASH_MODE_OFF; if ((is_err = is_IO(cam_handle_, IS_IO_CMD_FLASH_SET_MODE, (void*) &nMode, sizeof(nMode))) != IS_SUCCESS) { std::cerr << "Could not disable flash output for UEye camera '" << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl; return is_err; } if ((is_err = is_DisableEvent(cam_handle_, IS_SET_EVENT_FRAME)) != IS_SUCCESS) { std::cerr << "Could not disable frame event for UEye camera '" << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl; return is_err; } if ((is_err = is_StopLiveVideo(cam_handle_, IS_WAIT)) != IS_SUCCESS) { std::cerr << "Could not stop live video mode on UEye camera '" << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl; return is_err; } std::cout << "Stopped free-run live video mode on UEye camera '" + cam_name_ + "'" << std::endl; } if ((is_err = is_CameraStatus(cam_handle_, IS_STANDBY, IS_GET_STATUS)) != IS_SUCCESS) { std::cerr << "Could not set standby mode for UEye camera '" << cam_name_ << "' (" << err2str(is_err) << ")" << std::endl; return is_err; } return is_err; }
void UEyeCaptureInterface::SpinThread::run() { qDebug("new frame thread running"); while (capInterface->spinRunning.tryLock()) { //usleep(20000); if (capInterface->sync == SOFT_SYNC || capInterface->sync == FRAME_HARD_SYNC) { // printf("Both cameras fire!!!\n"); ueyeTrace(is_FreezeVideo (capInterface->rightCamera.mCamera, IS_DONT_WAIT)); ueyeTrace(is_FreezeVideo (capInterface->leftCamera .mCamera, IS_DONT_WAIT)); } int result = IS_SUCCESS; while ((result = capInterface->rightCamera.waitUEyeFrameEvent(INFINITE)) != IS_SUCCESS) { SYNC_PRINT(("WaitFrameEvent failed for right camera\n")); ueyeTrace(result); } //SYNC_PRINT(("Got right frame\n")); while ((result = capInterface->leftCamera .waitUEyeFrameEvent(INFINITE)) != IS_SUCCESS) { SYNC_PRINT(("WaitFrameEvent failed for left camera\n")); ueyeTrace(result); } //SYNC_PRINT(("Got left frame\n")); /* If we are here seems like both new cameras produced frames*/ int bufIDL, bufIDR; char *rawBufferLeft = NULL; char *rawBufferRight = NULL; HIDS mCameraLeft; HIDS mCameraRight; mCameraLeft = capInterface->leftCamera.mCamera; is_GetActSeqBuf(mCameraLeft, &bufIDL, NULL, &rawBufferLeft); is_LockSeqBuf (mCameraLeft, IS_IGNORE_PARAMETER, rawBufferLeft); mCameraRight = capInterface->rightCamera.mCamera; is_GetActSeqBuf(mCameraRight, &bufIDR, NULL, &rawBufferRight); is_LockSeqBuf (mCameraRight, IS_IGNORE_PARAMETER, rawBufferRight); // SYNC_PRINT(("We have locked buffers [%d and %d]\n", bufIDL, bufIDR)); /* Now exchange the buffer that is visible from */ capInterface->protectFrame.lock(); UEYEIMAGEINFO imageInfo; if (capInterface->currentLeft) is_UnlockSeqBuf (mCameraLeft, IS_IGNORE_PARAMETER, (char *)capInterface->currentLeft->buffer); is_GetImageInfo (mCameraLeft, bufIDL, &imageInfo, sizeof(UEYEIMAGEINFO)); capInterface->currentLeft = capInterface->leftCamera.getDescriptorByAddress(rawBufferLeft); capInterface->currentLeft->internalTimestamp = imageInfo.u64TimestampDevice; capInterface->currentLeft->pcTimestamp = imageInfo.TimestampSystem; if (capInterface->currentRight) is_UnlockSeqBuf (mCameraRight, IS_IGNORE_PARAMETER, (char *)capInterface->currentRight->buffer); is_GetImageInfo (mCameraRight, bufIDR, &imageInfo, sizeof(UEYEIMAGEINFO)); capInterface->currentRight = capInterface->rightCamera.getDescriptorByAddress(rawBufferRight); capInterface->currentRight->internalTimestamp = imageInfo.u64TimestampDevice; capInterface->currentRight->pcTimestamp = imageInfo.TimestampSystem; capInterface->skippedCount++; capInterface->triggerSkippedCount = is_CameraStatus (mCameraRight, IS_TRIGGER_MISSED, IS_GET_STATUS); capInterface->protectFrame.unlock(); /* For statistics */ if (capInterface->lastFrameTime.usecsTo(PreciseTimer()) != 0) { capInterface->frameDelay = capInterface->lastFrameTime.usecsToNow(); } capInterface->lastFrameTime = PreciseTimer::currentTime(); frame_data_t frameData; frameData.timestamp = (capInterface->currentLeft->usecsTimeStamp() / 2) + (capInterface->currentRight->usecsTimeStamp() / 2); capInterface->notifyAboutNewFrame(frameData); capInterface->spinRunning.unlock(); if (capInterface->shouldStopSpinThread) { qDebug("Break command received"); break; } } qDebug("new frame thread finished"); }