Esempio n. 1
0
UEyeCaptureInterface::~UEyeCaptureInterface()
{
    cout << "Request for killing the thread" << endl;
    shouldStopSpinThread = true;
    bool result = spinRunning.tryLock(1000);

    is_DisableEvent(leftCamera .mCamera, IS_SET_EVENT_FRAME);
    is_DisableEvent(rightCamera.mCamera, IS_SET_EVENT_FRAME);

#ifdef Q_OS_WIN
    is_ExitEvent (leftCamera .mCamera, IS_SET_EVENT_FRAME);
    is_ExitEvent (rightCamera.mCamera, IS_SET_EVENT_FRAME);

    CloseHandle(leftCamera .mWinEvent);
    CloseHandle(rightCamera.mWinEvent);
#endif

    if (result)
        printf("Camera thread killed\n");
    else
        printf("Unable to exit Camera thread\n");

    printf("Deleting image buffers\n");

    leftCamera.deAllocImages();
    rightCamera.deAllocImages();

    printf("uEye: Closing camera...");
    is_ExitCamera(leftCamera.mCamera);
    is_ExitCamera(rightCamera.mCamera);
    printf("done\n");

}
Esempio n. 2
0
bool IdsSourceSink::GrabFrame(ImagePacket &target, int indexIncrement)
{
    if (indexIncrement<0) qDebug()<<"Cannot stream backwards";

#ifdef Q_OS_WIN32
    if (WaitForSingleObject(hEvent, EVENTTHREAD_WAIT_TIMEOUT) == WAIT_OBJECT_0) {
#else
    if (is_WaitEvent (hCam, IS_SET_EVENT_FRAME, camTimeStep*5) == IS_SUCCESS) {
#endif
        void *pMemVoid; //pointer to where the image is stored  **********************
        is_GetImageMem (hCam, &pMemVoid);
        buffer.data =  (unsigned char*)pMemVoid;
        is_GetImageInfo( hCam, memId, &ImageInfo, sizeof(ImageInfo)); //Get info ASAP in case of an interruption due to a click
        target.image=buffer.clone();

        if (camTimeOffset==0) {
            camTimeOffset=3600000*ImageInfo.TimestampSystem.wHour+60000*ImageInfo.TimestampSystem.wMinute+1000.0*ImageInfo.TimestampSystem.wSecond+ImageInfo.TimestampSystem.wMilliseconds;
            target.timeStamp=0;
        } else {
            double tis;
            tis=3600000*ImageInfo.TimestampSystem.wHour+60000*ImageInfo.TimestampSystem.wMinute+1000.0*ImageInfo.TimestampSystem.wSecond+ImageInfo.TimestampSystem.wMilliseconds-camTimeOffset;
            target.timeStamp=tis;
        }
        target.seqNumber=ImageInfo.u64FrameNumber;

        target.pixFormat="MONO8";

    }

    return true;

}


bool IdsSourceSink::StopAcquisition() {
    is_StopLiveVideo(hCam, IS_WAIT);
    is_DisableEvent (hCam, IS_SET_EVENT_FRAME); //added by Sam
#ifdef Q_OS_WIN32
    is_ExitEvent(hCam, hEvent);
#endif
    is_FreeImageMem (hCam, imgMem, memId);
    Sleeper::msleep(10*camTimeStep); // NEEDS some sleep to stop all internal events
    return true;
}
void GUeyeCameraEventThread::run ()
{
    //printf ("start waiting on event %d\n", m_event);
    while (m_bRunEventThread)
    {
#ifdef __LINUX__
        if (is_WaitEvent (m_hCam, m_event, 1) == IS_SUCCESS)
#else
        if (WaitForSingleObject(m_hEvent, 1000) == WAIT_OBJECT_0)
#endif
        {
            //printf ("event %d detected\n", m_event);
            emit eventhappen (m_event);
        }
    }
    m_bRunEventThread = FALSE;
    is_DisableEvent (m_hCam, m_event);
#ifndef __LINUX__
    is_ExitEvent(m_hCam, m_event);
#endif
    //printf ("stop waiting on event %d\n", m_event);
}