Esempio n. 1
0
void CameraApi::lockMemory(char* memory)
{
	is_LockSeqBuf(mhCam, IS_IGNORE_PARAMETER, memory);
}
Esempio n. 2
0
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");
}