Hello,
i am a bit new in OpenCV and i hope someone can help me out, because i dont know what i am doing wrong...spending hours without any results :(
My first attempt is to try to save a live picture from my "ueye camera"
But i allways get the same error like this:
"OpenCV Error: Bad argument (Unknown array type) in cvarrToMat..."
i wrote my code in here too. I would be so glad if someone could help me out of this little problem...
code:
...
using namespace std;
using namespace cv;
void DImageproc::uEyeCapture()
{
HIDS m_hCam=1;
HWND m_hWndDisplay=NULL;
int m_nBitsPerPixel=32;
int m_nColorMode=0;
int m_nSizeX;
int m_nSizeY;
char* m_pcImageMemory=NULL;
int m_lMemoryId=0;
double dEnable = 1;
int ret = is_SetAutoParameter(m_hCam,IS_SET_ENABLE_AUTO_GAIN,&dEnable,0);
double soll = 128;
is_SetAutoParameter(m_hCam,IS_SET_AUTO_REFERENCE,&soll,0);
INT nRet = is_InitCamera(&m_hCam,m_hWndDisplay);
if(nRet != IS_SUCCESS)
{
cout << "Error: Camera not found" << endl;
abort();
}
if(nRet == IS_SUCCESS)
{
is_GetColorDepth(m_hCam,&m_nBitsPerPixel,&m_nColorMode);
if(is_SetColorMode(m_hCam,m_nColorMode) != IS_SUCCESS)
{ cout << "Error: Set ColorMode" << endl; }
}
INT *pnSizeX = &m_nSizeX;
INT *pnSizeY = &m_nSizeY;
INT nAOISupported = 0;
BOOL bAOISupported = TRUE;
if (is_ImageFormat (m_hCam,IMGFRMT_CMD_GET_ARBITRARY_AOI_SUPPORTED,(void*)&nAOISupported,sizeof(nAOISupported)) == IS_SUCCESS)
{
bAOISupported = (nAOISupported != 0);
}
if (bAOISupported)
{
SENSORINFO sInfo;
is_GetSensorInfo(m_hCam,&sInfo);
*pnSizeX = sInfo.nMaxWidth;
*pnSizeY = sInfo.nMaxHeight;
}
else
{
IS_RECT rectAOI;
rectAOI.s32X = 0;
rectAOI.s32Y = 0;
rectAOI.s32Width = m_nSizeX;
rectAOI.s32Height = m_nSizeY;
is_AOI(m_hCam,IS_AOI_IMAGE_SET_AOI,(void*)&rectAOI,sizeof(rectAOI));
}
nRet = is_AllocImageMem(m_hCam,m_nSizeX,m_nSizeY,m_nBitsPerPixel,&m_pcImageMemory,&m_lMemoryId);
nRet = is_SetImageMem(m_hCam, m_pcImageMemory, m_lMemoryId);
nRet = is_SetDisplayMode(m_hCam,IS_SET_DM_DIB);
if(nRet != IS_SUCCESS)
{
cout << "Error: is_SetDisplayMode" << endl;
}
if(m_hCam != 0)
{
is_FreezeVideo(m_hCam,IS_WAIT);
is_RenderBitmap(m_hCam,m_lMemoryId,m_hWndDisplay,IS_RENDER_FIT_TO_WINDOW);
IplImage *img = cvCreateImageHeader(cvSize(640,480),IPL_DEPTH_8S,3);
img->imageData = (char*) m_pcImageMemory;
cvSaveImage("test.jpg",img);
is_FreeImageMem(m_hCam,m_pcImageMemory,m_lMemoryId);
is_ExitCamera(m_hCam);
cvWaitKey(99);
}
}