DWORD WINAPI FlosIDSAdaptor::acquireThread(void* param)
{
    MSG msg;
    FlosIDSAdaptor* adaptor = reinterpret_cast<FlosIDSAdaptor *>(param);

    while(GetMessage(&msg, NULL, 0, 0) > 0) {
        switch(msg.message) {
        case WM_USER:
            std::auto_ptr<imaqkit::IAutoCriticalSection> driverSection(imaqkit::createAutoCriticalSection(adaptor->m_driverGuard, false));

            while(adaptor->isAcquisitionNotComplete() && adaptor->isAcquisitionActive()) {
            
                driverSection->enter();

                imaqkit::frametypes::FRAMETYPE frameType = adaptor->getFrameType();
                int imWidth  = adaptor->getMaxWidth();
                int imHeight = adaptor->getMaxHeight();

                INT   nMemID   = 0;
                char *pcBuffer = NULL;

                if((is_WaitForNextImage(adaptor->m_deviceID, 25, &pcBuffer, &nMemID)) == IS_SUCCESS) {
                    if(adaptor->isSendFrame()) {
                        imaqkit::IAdaptorFrame *frame = 
                            adaptor->getEngine()->makeFrame(frameType, imWidth, imHeight);

                        frame->setImage(pcBuffer, imWidth, imHeight, 0, 0);

                        frame->setTime(imaqkit::getCurrentTime());
                        adaptor->getEngine()->receiveFrame(frame);
                    }

                    is_UnlockSeqBuf(adaptor->m_deviceID, nMemID, pcBuffer);
                    adaptor->incrementFrameCount();
                }

                driverSection->leave();
            }

            break;
        }
   }
    
   return 0;
}
Beispiel #2
0
void CameraApi::unlockMemory(char* memory)
{
	is_UnlockSeqBuf(mhCam, IS_IGNORE_PARAMETER, memory);
}
Beispiel #3
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");
}