Hi there,
i have been trying to start ueye usb 1540 LE monochrome camera using opencv on ubuntu 14.04. program runs and camera is initialised also, memory is also allocated, but my window is showing blank images so far.any clues ??
here is my code... got this code from link text
//start camera//
void initializeCameraInterface(HIDS* hCam_internal) { // Open cam and see if it was succesfull
INT nRet = is_InitCamera (hCam_internal, NULL);
if (nRet == IS_SUCCESS){
cout << "Camera initialized!" << endl;
}
// Setting the pixel clock to retrieve data
UINT nPixelClockDefault = 24;
nRet = is_PixelClock(*hCam_internal, IS_PIXELCLOCK_CMD_SET, (void*)&nPixelClockDefault, sizeof(nPixelClockDefault));
if (nRet == IS_SUCCESS){
cout << "Camera pixel clock succesfully set!" << endl;
}else if(nRet == IS_NOT_SUPPORTED){
cout << "Camera pixel clock setting is not supported!" << endl;
}
// Set the color mode of the camera
INT colorMode = IS_CM_MONO8;
nRet = is_SetColorMode(*hCam_internal,colorMode);
if (nRet == IS_SUCCESS){
cout << "Camera color mode succesfully set!" << endl;
}
// Store image in camera memory --> option to chose data capture method
// Then access that memory to retrieve the data
INT displayMode = IS_SET_DM_DIB;
nRet = is_SetDisplayMode (*hCam_internal, displayMode);
if (nRet == IS_SUCCESS){
cout << "display mode succesfully set!" << endl;
}
}
// Capture a frame and push it in a OpenCV mat element
Mat getFrame(HIDS* hCam, int width, int height, cv::Mat& mat) { // Allocate memory for image
char* pMem = NULL;
int memID = 0;
if( is_AllocImageMem(*hCam, width, height, 8, &pMem, &memID) == IS_SUCCESS)
{
//cout<< "allocation successful" <<endl;< p="">
};
// Activate the image memory for storing the frame captured
// Grabbing the image
// Getting the data of the frame and push it in a Mat element
is_SetImageMem(*hCam, pMem, memID);
// is_FreezeVideo(*hCam, IS_WAIT);
//is_SetImageSize(*hCam,width,height);
//is_SetImagePos(*hCam, 0, 0);
is_FreezeVideo(*hCam, IS_WAIT);
//cout<< "debug 1"<<endl;< p="">
VOID* pMem_b;
int retInt = is_GetImageMem(*hCam, &pMem_b);
if (retInt != IS_SUCCESS) {
cout << "Image data could not be read from memory!" << endl;
}
else{
//cout << "Image data read from memory!" << endl;
}
if (memcpy(mat.ptr(), pMem_b, sizeof(mat) ));
cout<<"memory copied"<<endl;
return mat;
}
int main() { // --------------------------------------------------------------------------------------------------------------- // START BY CONFIGURING THE INTERFACE WITH THE UEYE CAMERA // ---------------------------------------------------------------------------------------------------------------
// Camera initialisation
// Index 0 means taking the first camera available
HIDS hCam = 0;
initializeCameraInterface(&hCam);
namedWindow("test interface", CV_WINDOW_AUTOSIZE);
// ---------------------------------------------------------------------------------------------------------------
// CAPTURE DATA AND PROCESS
// ---------------------------------------------------------------------------------------------------------------
while(true){
// Create an image and grab a frame
Mat current_image (400, 400, CV_8UC1);
getFrame(&hCam, 400, 400, current_image);
// PERFORM YOUR OPENCV PROCESSING HERE!
// Visualise the data
imshow("test_interface", current_image);
// Check if we need to stop processing
if ( (int)waitKey(10) >= 0 ){
break;
}
}
// Release the camera again
is_ExitCamera(hCam);
return 0;
}