Commit 8b0fc04d authored by Philippe FOUBERT's avatar Philippe FOUBERT

Fix the build of OpenCV with XIMEA on Windows 64 bits:

  - crosses initializations in "cap_ximea.cpp" (which also contained some awfull "goto" instructions)
  - the "CMAKE_CL_64" variable is not initialized when using mingw

PR#1039 modified to be able to merge on branch 2.4
parent 0ac61240
...@@ -23,7 +23,7 @@ if(WIN32) ...@@ -23,7 +23,7 @@ if(WIN32)
if(EXISTS ${XIMEA_PATH}) if(EXISTS ${XIMEA_PATH})
set(XIMEA_FOUND 1) set(XIMEA_FOUND 1)
# set LIB folders # set LIB folders
if(CMAKE_CL_64) if(X86_64)
set(XIMEA_LIBRARY_DIR "${XIMEA_PATH}/x64") set(XIMEA_LIBRARY_DIR "${XIMEA_PATH}/x64")
else() else()
set(XIMEA_LIBRARY_DIR "${XIMEA_PATH}/x86") set(XIMEA_LIBRARY_DIR "${XIMEA_PATH}/x86")
......
...@@ -167,9 +167,9 @@ if(HAVE_XIMEA) ...@@ -167,9 +167,9 @@ if(HAVE_XIMEA)
list(APPEND highgui_srcs src/cap_ximea.cpp) list(APPEND highgui_srcs src/cap_ximea.cpp)
ocv_include_directories(${XIMEA_PATH}) ocv_include_directories(${XIMEA_PATH})
if(XIMEA_LIBRARY_DIR) if(XIMEA_LIBRARY_DIR)
link_directories(${XIMEA_LIBRARY_DIR}) link_directories("${XIMEA_LIBRARY_DIR}")
endif() endif()
if(CMAKE_CL_64) if(X86_64)
list(APPEND HIGHGUI_LIBRARIES m3apiX64) list(APPEND HIGHGUI_LIBRARIES m3apiX64)
else() else()
list(APPEND HIGHGUI_LIBRARIES m3api) list(APPEND HIGHGUI_LIBRARIES m3api)
......
...@@ -62,74 +62,95 @@ void CvCaptureCAM_XIMEA::init() ...@@ -62,74 +62,95 @@ void CvCaptureCAM_XIMEA::init()
// Initialize camera input // Initialize camera input
bool CvCaptureCAM_XIMEA::open( int wIndex ) bool CvCaptureCAM_XIMEA::open( int wIndex )
{ {
#define HandleXiResult(res) if (res!=XI_OK) goto error; bool res = true;
int mvret = XI_OK; int mvret = XI_OK;
if(numDevices == 0) if(0 == numDevices)
return false;
if((mvret = xiOpenDevice( wIndex, &hmv)) != XI_OK)
{ {
errMsg("Open XI_DEVICE failed", mvret); res = false;
return false;
} }
else if(XI_OK != (mvret = xiOpenDevice(wIndex, &hmv)))
// always use auto exposure/gain
mvret = xiSetParamInt( hmv, XI_PRM_AEAG, 1);
HandleXiResult(mvret);
int width = 0;
mvret = xiGetParamInt( hmv, XI_PRM_WIDTH, &width);
HandleXiResult(mvret);
int height = 0;
mvret = xiGetParamInt( hmv, XI_PRM_HEIGHT, &height);
HandleXiResult(mvret);
int isColor = 0;
mvret = xiGetParamInt(hmv, XI_PRM_IMAGE_IS_COLOR, &isColor);
HandleXiResult(mvret);
if(isColor) // for color cameras
{ {
// default image format RGB24 errMsg("Open XI_DEVICE failed", mvret);
mvret = xiSetParamInt( hmv, XI_PRM_IMAGE_DATA_FORMAT, XI_RGB24); res = false;
HandleXiResult(mvret);
// always use auto white ballance for color cameras
mvret = xiSetParamInt( hmv, XI_PRM_AUTO_WB, 1);
HandleXiResult(mvret);
// allocate frame buffer for RGB24 image
frame = cvCreateImage(cvSize( width, height), IPL_DEPTH_8U, 3);
} }
else // for mono cameras else
{ {
// default image format MONO8 int width = 0;
mvret = xiSetParamInt( hmv, XI_PRM_IMAGE_DATA_FORMAT, XI_MONO8); int height = 0;
HandleXiResult(mvret); int isColor = 0;
// allocate frame buffer for MONO8 image // always use auto exposure/gain
frame = cvCreateImage(cvSize( width, height), IPL_DEPTH_8U, 1); if(XI_OK != (mvret = xiSetParamInt(hmv, XI_PRM_AEAG, 1)))
} {
res = false;
}
else if(XI_OK != (mvret = xiGetParamInt(hmv, XI_PRM_WIDTH, &width)))
{
res = false;
}
else if(XI_OK != (mvret = xiGetParamInt(hmv, XI_PRM_HEIGHT, &height)))
{
res = false;
}
else if(XI_OK != (mvret = xiGetParamInt(hmv, XI_PRM_IMAGE_IS_COLOR, &isColor)))
{
res = false;
}
else
{
if(isColor) // for color cameras
{
// default image format RGB24
if(XI_OK != (mvret = xiSetParamInt(hmv, XI_PRM_IMAGE_DATA_FORMAT, XI_RGB24)))
{
res = false;
}
// always use auto white ballance for color cameras
else if(XI_OK != (mvret = xiSetParamInt(hmv, XI_PRM_AUTO_WB, 1)))
{
res = false;
}
else
{
// allocate frame buffer for RGB24 image
frame = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3);
}
}
else // for mono cameras
{
// default image format MONO8
if(XI_OK != (mvret = xiSetParamInt(hmv, XI_PRM_IMAGE_DATA_FORMAT, XI_MONO8)))
{
res = false;
}
else
{
// allocate frame buffer for MONO8 image
frame = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 1);
}
}
}
//default capture timeout 10s if(true == res)
timeout = 10000; {
//default capture timeout 10s
timeout = 10000;
mvret = xiStartAcquisition(hmv); if(XI_OK != (mvret = xiStartAcquisition(hmv)))
if(mvret != XI_OK) {
{ errMsg("StartAcquisition XI_DEVICE failed", mvret);
errMsg("StartAcquisition XI_DEVICE failed", mvret); res = false;
goto error; }
}
else
{
errMsg("Open XI_DEVICE failed", mvret);
xiCloseDevice(hmv);
hmv = NULL;
}
} }
return true; return true;
error:
errMsg("Open XI_DEVICE failed", mvret);
xiCloseDevice(hmv);
hmv = NULL;
return false;
} }
/**********************************************************************************/ /**********************************************************************************/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment