Example #1
0
//////////////////////////////////////////////////////////////////////////////////
// OpenCamera --------------------------------------------------------------------
//////////////////////////////////////////////////////////////////////////////////
BOOL ofxUeye::OpenCamera(int id){
	int nRet;

    m_hCam = (HCAM)id; 
    nRet = InitCamera (&m_hCam, m_hwndDisp);    // init camera
    if( nRet == IS_SUCCESS )
    {
        is_GetCameraInfo( m_hCam, &m_ci);

        // retrieve original image size
        is_GetSensorInfo( m_hCam, &m_si);

        GetMaxImageSize(&m_nSizeX, &m_nSizeY);

        // setup the bitmap or directdraw display mode
        nRet = InitDisplayMode();

        if(nRet == IS_SUCCESS)
        {
            // Enable Messages
            nRet = is_EnableMessage( m_hCam, IS_DEVICE_REMOVED, m_hwndDisp );
            nRet = is_EnableMessage( m_hCam, IS_DEVICE_RECONNECTED, m_hwndDisp );
            nRet = is_EnableMessage( m_hCam, IS_FRAME, m_hwndDisp );
        }   // end if( nRet == IS_SUCCESS )
    }   // end if( nRet == IS_SUCCESS )

    return (nRet == IS_SUCCESS);
}
INT WINAPI StartRunning(HIDS* m_hCam, const wchar_t* settingsFile, int* nMonitorId, void (WINAPI*OnWindowShow)(BOOL), HWND hWnd) { 
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	m_monitorId = nMonitorId;
	INT result = IS_SUCCESS;
	if (!m_bRunning && m_hCam) {
		if (!m_renderThread) {
			if( LoadSettings(m_hCam, settingsFile) != IS_SUCCESS) {
				// if settings from file cannot be loaded, then use default maximum size for the sensor
				GetMaxImageSize(m_hCam, &m_nSizeX, &m_nSizeY);
			}
			result = InitDisplayMode(m_hCam);
			if (result == IS_SUCCESS && !m_renderThread) {
				// start a new thread that will create a window to show the live video fullscreen
				m_renderThread = (CuEyeRenderThread *) AfxBeginThread(RUNTIME_CLASS(CuEyeRenderThread), THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
				// set to false to prevent uncontrolled m_renderThread pointer invalidation
				m_renderThread->m_bAutoDelete = FALSE; 
				m_renderThread->Initialize(m_hCam, m_pcImageMemory, &m_lMemoryId, nMonitorId, OnWindowShow, hWnd);
				m_renderThread->ResumeThread();
			}
		} else if (!m_renderThread->m_pMainWnd && m_renderThread->GetHwnd() != hWnd) {
			// stop running was called and window handle invalidated
			PostThreadMessage(m_renderThread->m_nThreadID, IS_THREAD_MESSAGE, SET_HWND, (LPARAM) hWnd);
		}
		// start live video
		result |= is_CaptureVideo( *m_hCam, IS_DONT_WAIT );
		m_bRunning = TRUE;
	}
	return result;
}
Example #3
0
void GCamera::SelectFullAOI()
{
	if(!m_IsOpened)
		return;
	QRect maxImageRect(QPoint(0, 0), GetMaxImageSize());
	// compare the expected AOI to the one actually used. It should be the same!
	QRect returnedAOI = SetSensorAOI(maxImageRect);
	if(returnedAOI != maxImageRect)
		qWarning() << "GCamera::SelectFullAOI(), the maximal AOI used:" << returnedAOI << "is different from the maximal expected AOI:" << maxImageRect;
}