I have a VC++ project to program a camera, framegabber and also displaying live capturing using OpenCV. the prblem is that the program works fine in Debug mode and it shows the live capturing from the camera, however when I change it to the Release mode the .exe file of the program doesnt hide the window ands it doesnt show any thing from the camera. here is mycode:

//allocate memory
if((_memoryAllc = Fg_AllocMemEx(fg,totalBufSize, CG_Options::getNBuffer()))!=NULL){         
    if(Fg_AcquireEx(fg,nCamPort,GRAB_INFINITE,ACQ_STANDARD,_memoryAllc)<0){
        CExceptionHandler::GrabberErrorMessage(fg,"Can not start Acquiring images .");  
    }
    else{                   
        //create a window and set the handler from openCV to win32 
        cv::namedWindow("test",cv::WINDOW_AUTOSIZE);                        
        hWnd2 = (HWND) cvGetWindowHandle("test");   
        hParent = ::GetParent(hWnd2);                               
        ::SetParent(hWnd2, hWnd); 
        ::ShowWindow(hParent, SW_HIDE); 
        _liveCapturing=true;
        lastPicNr = 0;  
        SetWindowTextW(hStatus, L"Live Capturing ... ");

        while(IsWindowVisible(hWnd2)){ //show the data while the window is open and visible
            lastPicNr = Fg_getLastPicNumberBlockingEx(fg,lastPicNr+1,nCamPort,10,_memoryAllc);                          
            iPtr=(unsigned char*)Fg_getImagePtrEx(fg,lastPicNr,0,_memoryAllc);                      
            cv::Mat _matrixImage(cv::Size(CG_Options::getWidth(),CG_Options::getHeight()), CV_8UC1,iPtr , cv::Mat::AUTO_STEP);                                                                                              
            cv::imshow("test",_matrixImage);
            cv::waitKey(10);
        }                       
    }
}

Anybody has any idea?

有帮助吗?

解决方案

Make sure you are linking all necessary libraries in project properties. You have to set these properties for both debug and release modes. I would also revisit preprocessor definitions (project properties -> configuration properties -> C/C++ -> Preprocessor -> Preprocessor definitions) for both debug and release configuration modes.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top