Fixed PvAPI search on Windows #1927
This commit is contained in:
parent
6455488ff4
commit
e161f428a0
@ -171,7 +171,7 @@ elseif(MSVC_IDE)
|
|||||||
set(ENABLE_SOLUTION_FOLDERS0 ON)
|
set(ENABLE_SOLUTION_FOLDERS0 ON)
|
||||||
else()
|
else()
|
||||||
set(ENABLE_SOLUTION_FOLDERS0 OFF)
|
set(ENABLE_SOLUTION_FOLDERS0 OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# OpenCV build options
|
# OpenCV build options
|
||||||
# ===================================================
|
# ===================================================
|
||||||
@ -312,7 +312,7 @@ if(UNIX)
|
|||||||
include(cmake/OpenCVFindPkgConfig.cmake OPTIONAL)
|
include(cmake/OpenCVFindPkgConfig.cmake OPTIONAL)
|
||||||
include(CheckFunctionExists)
|
include(CheckFunctionExists)
|
||||||
include(CheckIncludeFile)
|
include(CheckIncludeFile)
|
||||||
|
|
||||||
if(NOT APPLE)
|
if(NOT APPLE)
|
||||||
CHECK_INCLUDE_FILE(alloca.h HAVE_ALLOCA_H)
|
CHECK_INCLUDE_FILE(alloca.h HAVE_ALLOCA_H)
|
||||||
CHECK_FUNCTION_EXISTS(alloca HAVE_ALLOCA)
|
CHECK_FUNCTION_EXISTS(alloca HAVE_ALLOCA)
|
||||||
@ -408,11 +408,32 @@ endif(WITH_UNICAP)
|
|||||||
ocv_clear_vars(HAVE_PVAPI)
|
ocv_clear_vars(HAVE_PVAPI)
|
||||||
if(WITH_PVAPI)
|
if(WITH_PVAPI)
|
||||||
find_path(PVAPI_INCLUDE_PATH "PvApi.h"
|
find_path(PVAPI_INCLUDE_PATH "PvApi.h"
|
||||||
PATHS "/usr/local/include" "/usr/include"
|
PATHS /usr/local /opt /usr ENV ProgramFiles ENV ProgramW6432
|
||||||
|
PATH_SUFFIXES include "Allied Vision Technologies/GigESDK/inc-pc" "AVT GigE SDK/inc-pc" "GigESDK/inc-pc"
|
||||||
DOC "The path to PvAPI header")
|
DOC "The path to PvAPI header")
|
||||||
|
|
||||||
if(PVAPI_INCLUDE_PATH)
|
if(PVAPI_INCLUDE_PATH)
|
||||||
set(HAVE_PVAPI TRUE)
|
if(X86 AND NOT WIN32)
|
||||||
endif()
|
set(PVAPI_SDK_SUBDIR x86)
|
||||||
|
elseif(X86_64)
|
||||||
|
set(PVAPI_SDK_SUBDIR x64)
|
||||||
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES arm)
|
||||||
|
set(PVAPI_SDK_SUBDIR arm)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
get_filename_component(_PVAPI_LIBRARY "${PVAPI_INCLUDE_PATH}/../lib-pc" ABSOLUTE)
|
||||||
|
if(PVAPI_SDK_SUBDIR)
|
||||||
|
set(_PVAPI_LIBRARY "${_PVAPI_LIBRARY}/${PVAPI_SDK_SUBDIR}")
|
||||||
|
endif()
|
||||||
|
if(NOT WIN32 AND CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
set(_PVAPI_LIBRARY "${_PVAPI_LIBRARY}/${CMAKE_OPENCV_GCC_VERSION_MAJOR}.${CMAKE_OPENCV_GCC_VERSION_MINOR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(PVAPI_LIBRARY "${_PVAPI_LIBRARY}/${CMAKE_STATIC_LIBRARY_PREFIX}PvAPI${CMAKE_STATIC_LIBRARY_SUFFIX}" CACHE PATH "The PvAPI library")
|
||||||
|
if(EXISTS "${PVAPI_LIBRARY}")
|
||||||
|
set(HAVE_PVAPI TRUE)
|
||||||
|
endif()
|
||||||
|
endif(PVAPI_INCLUDE_PATH)
|
||||||
endif(WITH_PVAPI)
|
endif(WITH_PVAPI)
|
||||||
|
|
||||||
# --- Dc1394 ---
|
# --- Dc1394 ---
|
||||||
@ -463,7 +484,7 @@ if(WITH_FFMPEG)
|
|||||||
CHECK_MODULE(libavformat HAVE_FFMPEG_FORMAT)
|
CHECK_MODULE(libavformat HAVE_FFMPEG_FORMAT)
|
||||||
CHECK_MODULE(libavutil HAVE_FFMPEG_UTIL)
|
CHECK_MODULE(libavutil HAVE_FFMPEG_UTIL)
|
||||||
CHECK_MODULE(libswscale HAVE_FFMPEG_SWSCALE)
|
CHECK_MODULE(libswscale HAVE_FFMPEG_SWSCALE)
|
||||||
|
|
||||||
CHECK_INCLUDE_FILE(libavformat/avformat.h HAVE_GENTOO_FFMPEG)
|
CHECK_INCLUDE_FILE(libavformat/avformat.h HAVE_GENTOO_FFMPEG)
|
||||||
CHECK_INCLUDE_FILE(ffmpeg/avformat.h HAVE_FFMPEG_FFMPEG)
|
CHECK_INCLUDE_FILE(ffmpeg/avformat.h HAVE_FFMPEG_FFMPEG)
|
||||||
if(NOT HAVE_GENTOO_FFMPEG AND NOT HAVE_FFMPEG_FFMPEG)
|
if(NOT HAVE_GENTOO_FFMPEG AND NOT HAVE_FFMPEG_FFMPEG)
|
||||||
@ -592,7 +613,7 @@ if(WITH_CLP)
|
|||||||
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CLP_LIBRARIES})
|
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CLP_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT CLP_FOUND)
|
if(NOT CLP_FOUND)
|
||||||
find_path(CLP_INCLUDE_PATH "coin"
|
find_path(CLP_INCLUDE_PATH "coin"
|
||||||
PATHS "/usr/local/include" "/usr/include" "/opt/include"
|
PATHS "/usr/local/include" "/usr/include" "/opt/include"
|
||||||
@ -607,7 +628,7 @@ if(WITH_CLP)
|
|||||||
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} libClp libCoinUtils)
|
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} libClp libCoinUtils)
|
||||||
endif()
|
endif()
|
||||||
set(HAVE_CLP TRUE)
|
set(HAVE_CLP TRUE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif(WITH_CLP)
|
endif(WITH_CLP)
|
||||||
|
|
||||||
@ -623,7 +644,7 @@ include(cmake/OpenCVDetectPython.cmake REQUIRED)
|
|||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
include(cmake/OpenCVDetectApacheAnt.cmake REQUIRED)
|
include(cmake/OpenCVDetectApacheAnt.cmake REQUIRED)
|
||||||
include(cmake/OpenCVDetectAndroidSDK.cmake REQUIRED)
|
include(cmake/OpenCVDetectAndroidSDK.cmake REQUIRED)
|
||||||
|
|
||||||
if(NOT ANDROID_TOOLS_Pkg_Revision GREATER 13)
|
if(NOT ANDROID_TOOLS_Pkg_Revision GREATER 13)
|
||||||
message(WARNING "OpenCV requires Android SDK tools revision 14 or newer. Otherwise tests and samples will no be compiled.")
|
message(WARNING "OpenCV requires Android SDK tools revision 14 or newer. Otherwise tests and samples will no be compiled.")
|
||||||
endif()
|
endif()
|
||||||
|
@ -96,7 +96,7 @@ elseif(APPLE)
|
|||||||
list(APPEND HIGHGUI_LIBRARIES "-framework Cocoa")
|
list(APPEND HIGHGUI_LIBRARIES "-framework Cocoa")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
list(APPEND highgui_srcs src/cap_vfw.cpp src/cap_cmu.cpp src/cap_dshow.cpp)
|
list(APPEND highgui_srcs src/cap_vfw.cpp src/cap_cmu.cpp src/cap_dshow.cpp)
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
@ -157,19 +157,8 @@ endif(HAVE_FFMPEG)
|
|||||||
if(HAVE_PVAPI)
|
if(HAVE_PVAPI)
|
||||||
add_definitions(-DHAVE_PVAPI)
|
add_definitions(-DHAVE_PVAPI)
|
||||||
ocv_include_directories(${PVAPI_INCLUDE_PATH})
|
ocv_include_directories(${PVAPI_INCLUDE_PATH})
|
||||||
if(X86)
|
|
||||||
set(PVAPI_SDK_SUBDIR x86)
|
|
||||||
elseif(X86_64)
|
|
||||||
set(PVAPI_SDK_SUBDIR x64)
|
|
||||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES arm)
|
|
||||||
set(PVAPI_SDK_SUBDIR arm)
|
|
||||||
endif()
|
|
||||||
if(PVAPI_SDK_SUBDIR AND CMAKE_COMPILER_IS_GNUCXX)
|
|
||||||
get_filename_component(PVAPI_EXPECTED_LIB_PATH "${PVAPI_INCLUDE_PATH}/../lib-pc/${PVAPI_SDK_SUBDIR}/${CMAKE_OPENCV_GCC_VERSION_MAJOR}.${CMAKE_OPENCV_GCC_VERSION_MINOR}" ABSOLUTE)
|
|
||||||
link_directories(${PVAPI_EXPECTED_LIB_PATH})
|
|
||||||
endif()
|
|
||||||
set(highgui_srcs src/cap_pvapi.cpp ${highgui_srcs})
|
set(highgui_srcs src/cap_pvapi.cpp ${highgui_srcs})
|
||||||
set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} PvAPI)
|
list(APPEND HIGHGUI_LIBRARIES ${PVAPI_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WITH_IMAGEIO)
|
if(WITH_IMAGEIO)
|
||||||
@ -241,11 +230,11 @@ if(WIN32 AND WITH_FFMPEG)
|
|||||||
if(MSVC64 OR MINGW64)
|
if(MSVC64 OR MINGW64)
|
||||||
set(FFMPEG_SUFFIX _64)
|
set(FFMPEG_SUFFIX _64)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(ffmpeg_bare_name "opencv_ffmpeg${FFMPEG_SUFFIX}.dll")
|
set(ffmpeg_bare_name "opencv_ffmpeg${FFMPEG_SUFFIX}.dll")
|
||||||
set(ffmpeg_bare_name_ver "opencv_ffmpeg${OPENCV_DLLVERSION}${FFMPEG_SUFFIX}.dll")
|
set(ffmpeg_bare_name_ver "opencv_ffmpeg${OPENCV_DLLVERSION}${FFMPEG_SUFFIX}.dll")
|
||||||
set(ffmpeg_path "${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/${ffmpeg_bare_name}")
|
set(ffmpeg_path "${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/${ffmpeg_bare_name}")
|
||||||
|
|
||||||
#if(MSVC AND CMAKE_VERSION VERSION_GREATER "2.8.2")
|
#if(MSVC AND CMAKE_VERSION VERSION_GREATER "2.8.2")
|
||||||
# add_custom_command(TARGET ${the_module} POST_BUILD
|
# add_custom_command(TARGET ${the_module} POST_BUILD
|
||||||
# COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/$<CONFIGURATION>/${ffmpeg_bare_name_ver}"
|
# COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/$<CONFIGURATION>/${ffmpeg_bare_name_ver}"
|
||||||
@ -265,7 +254,7 @@ if(WIN32 AND WITH_FFMPEG)
|
|||||||
COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/${ffmpeg_bare_name_ver}"
|
COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/${ffmpeg_bare_name_ver}"
|
||||||
COMMENT "Copying ${ffmpeg_path} to the output directory")
|
COMMENT "Copying ${ffmpeg_path} to the output directory")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(FILES "${ffmpeg_path}" DESTINATION bin COMPONENT main RENAME "${ffmpeg_bare_name_ver}")
|
install(FILES "${ffmpeg_path}" DESTINATION bin COMPONENT main RENAME "${ffmpeg_bare_name_ver}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -57,7 +57,12 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <PvApi.h>
|
#include <PvApi.h>
|
||||||
#include <unistd.h>
|
#ifdef WIN32
|
||||||
|
# include <io.h>
|
||||||
|
#else
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
//#include <arpa/inet.h>
|
//#include <arpa/inet.h>
|
||||||
|
|
||||||
@ -69,7 +74,7 @@ class CvCaptureCAM_PvAPI : public CvCapture
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CvCaptureCAM_PvAPI();
|
CvCaptureCAM_PvAPI();
|
||||||
virtual ~CvCaptureCAM_PvAPI()
|
virtual ~CvCaptureCAM_PvAPI()
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
@ -80,52 +85,55 @@ public:
|
|||||||
virtual bool setProperty(int, double);
|
virtual bool setProperty(int, double);
|
||||||
virtual bool grabFrame();
|
virtual bool grabFrame();
|
||||||
virtual IplImage* retrieveFrame(int);
|
virtual IplImage* retrieveFrame(int);
|
||||||
virtual int getCaptureDomain()
|
virtual int getCaptureDomain()
|
||||||
{
|
{
|
||||||
return CV_CAP_PVAPI;
|
return CV_CAP_PVAPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Sleep(unsigned int time);
|
#ifndef WIN32
|
||||||
|
virtual void Sleep(unsigned int time);
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
unsigned long UID;
|
unsigned long UID;
|
||||||
tPvHandle Handle;
|
tPvHandle Handle;
|
||||||
tPvFrame Frame;
|
tPvFrame Frame;
|
||||||
|
|
||||||
|
|
||||||
} tCamera;
|
} tCamera;
|
||||||
|
|
||||||
IplImage *frame;
|
IplImage *frame;
|
||||||
IplImage *grayframe;
|
IplImage *grayframe;
|
||||||
tCamera Camera;
|
tCamera Camera;
|
||||||
tPvErr Errcode;
|
tPvErr Errcode;
|
||||||
bool monocrome;
|
bool monocrome;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
CvCaptureCAM_PvAPI::CvCaptureCAM_PvAPI()
|
CvCaptureCAM_PvAPI::CvCaptureCAM_PvAPI()
|
||||||
{
|
{
|
||||||
monocrome=false;
|
monocrome=false;
|
||||||
memset(&this->Camera, 0, sizeof(this->Camera));
|
memset(&this->Camera, 0, sizeof(this->Camera));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
void CvCaptureCAM_PvAPI::Sleep(unsigned int time)
|
void CvCaptureCAM_PvAPI::Sleep(unsigned int time)
|
||||||
{
|
{
|
||||||
struct timespec t,r;
|
struct timespec t,r;
|
||||||
|
|
||||||
t.tv_sec = time / 1000;
|
t.tv_sec = time / 1000;
|
||||||
t.tv_nsec = (time % 1000) * 1000000;
|
t.tv_nsec = (time % 1000) * 1000000;
|
||||||
|
|
||||||
while(nanosleep(&t,&r)==-1)
|
while(nanosleep(&t,&r)==-1)
|
||||||
t = r;
|
t = r;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void CvCaptureCAM_PvAPI::close()
|
void CvCaptureCAM_PvAPI::close()
|
||||||
{
|
{
|
||||||
// Stop the acquisition & free the camera
|
// Stop the acquisition & free the camera
|
||||||
PvCommandRun(Camera.Handle, "AcquisitionStop");
|
PvCommandRun(Camera.Handle, "AcquisitionStop");
|
||||||
PvCaptureEnd(Camera.Handle);
|
PvCaptureEnd(Camera.Handle);
|
||||||
PvCameraClose(Camera.Handle);
|
PvCameraClose(Camera.Handle);
|
||||||
PvUnInitialize();
|
PvUnInitialize();
|
||||||
}
|
}
|
||||||
@ -134,47 +142,47 @@ void CvCaptureCAM_PvAPI::close()
|
|||||||
bool CvCaptureCAM_PvAPI::open( int index )
|
bool CvCaptureCAM_PvAPI::open( int index )
|
||||||
{
|
{
|
||||||
tPvCameraInfo cameraList[MAX_CAMERAS];
|
tPvCameraInfo cameraList[MAX_CAMERAS];
|
||||||
|
|
||||||
tPvCameraInfo camInfo;
|
tPvCameraInfo camInfo;
|
||||||
tPvIpSettings ipSettings;
|
tPvIpSettings ipSettings;
|
||||||
|
|
||||||
|
|
||||||
if (PvInitialize()) {
|
if (PvInitialize()) {
|
||||||
}
|
}
|
||||||
//return false;
|
//return false;
|
||||||
|
|
||||||
Sleep(1000);
|
Sleep(1000);
|
||||||
|
|
||||||
//close();
|
//close();
|
||||||
|
|
||||||
int numCameras=PvCameraList(cameraList, MAX_CAMERAS, NULL);
|
int numCameras=PvCameraList(cameraList, MAX_CAMERAS, NULL);
|
||||||
|
|
||||||
if (numCameras <= 0 || index >= numCameras)
|
if (numCameras <= 0 || index >= numCameras)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Camera.UID = cameraList[index].UniqueId;
|
Camera.UID = cameraList[index].UniqueId;
|
||||||
|
|
||||||
if (!PvCameraInfo(Camera.UID,&camInfo) && !PvCameraIpSettingsGet(Camera.UID,&ipSettings)) {
|
if (!PvCameraInfo(Camera.UID,&camInfo) && !PvCameraIpSettingsGet(Camera.UID,&ipSettings)) {
|
||||||
/*
|
/*
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
addr.s_addr = ipSettings.CurrentIpAddress;
|
addr.s_addr = ipSettings.CurrentIpAddress;
|
||||||
printf("Current address:\t%s\n",inet_ntoa(addr));
|
printf("Current address:\t%s\n",inet_ntoa(addr));
|
||||||
addr.s_addr = ipSettings.CurrentIpSubnet;
|
addr.s_addr = ipSettings.CurrentIpSubnet;
|
||||||
printf("Current subnet:\t\t%s\n",inet_ntoa(addr));
|
printf("Current subnet:\t\t%s\n",inet_ntoa(addr));
|
||||||
addr.s_addr = ipSettings.CurrentIpGateway;
|
addr.s_addr = ipSettings.CurrentIpGateway;
|
||||||
printf("Current gateway:\t%s\n",inet_ntoa(addr));
|
printf("Current gateway:\t%s\n",inet_ntoa(addr));
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stderr,"ERROR: could not retrieve camera IP settings.\n");
|
fprintf(stderr,"ERROR: could not retrieve camera IP settings.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (PvCameraOpen(Camera.UID, ePvAccessMaster, &(Camera.Handle))==ePvErrSuccess)
|
if (PvCameraOpen(Camera.UID, ePvAccessMaster, &(Camera.Handle))==ePvErrSuccess)
|
||||||
{
|
{
|
||||||
|
|
||||||
//Set Pixel Format to BRG24 to follow conventions
|
//Set Pixel Format to BRG24 to follow conventions
|
||||||
/*Errcode = PvAttrEnumSet(Camera.Handle, "PixelFormat", "Bgr24");
|
/*Errcode = PvAttrEnumSet(Camera.Handle, "PixelFormat", "Bgr24");
|
||||||
if (Errcode != ePvErrSuccess)
|
if (Errcode != ePvErrSuccess)
|
||||||
{
|
{
|
||||||
@ -184,7 +192,7 @@ bool CvCaptureCAM_PvAPI::open( int index )
|
|||||||
*/
|
*/
|
||||||
tPvUint32 frameWidth, frameHeight, frameSize;
|
tPvUint32 frameWidth, frameHeight, frameSize;
|
||||||
unsigned long maxSize;
|
unsigned long maxSize;
|
||||||
char pixelFormat[256];
|
char pixelFormat[256];
|
||||||
PvAttrUint32Get(Camera.Handle, "TotalBytesPerFrame", &frameSize);
|
PvAttrUint32Get(Camera.Handle, "TotalBytesPerFrame", &frameSize);
|
||||||
PvAttrUint32Get(Camera.Handle, "Width", &frameWidth);
|
PvAttrUint32Get(Camera.Handle, "Width", &frameWidth);
|
||||||
PvAttrUint32Get(Camera.Handle, "Height", &frameHeight);
|
PvAttrUint32Get(Camera.Handle, "Height", &frameHeight);
|
||||||
@ -192,31 +200,31 @@ bool CvCaptureCAM_PvAPI::open( int index )
|
|||||||
maxSize = 8228;
|
maxSize = 8228;
|
||||||
//PvAttrUint32Get(Camera.Handle,"PacketSize",&maxSize);
|
//PvAttrUint32Get(Camera.Handle,"PacketSize",&maxSize);
|
||||||
if (PvCaptureAdjustPacketSize(Camera.Handle,maxSize)!=ePvErrSuccess)
|
if (PvCaptureAdjustPacketSize(Camera.Handle,maxSize)!=ePvErrSuccess)
|
||||||
return false;
|
return false;
|
||||||
if (strcmp(pixelFormat, "Mono8")==0) {
|
if (strcmp(pixelFormat, "Mono8")==0) {
|
||||||
grayframe = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 1);
|
grayframe = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 1);
|
||||||
grayframe->widthStep = (int)frameWidth;
|
grayframe->widthStep = (int)frameWidth;
|
||||||
frame = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 3);
|
frame = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 3);
|
||||||
frame->widthStep = (int)frameWidth*3;
|
frame->widthStep = (int)frameWidth*3;
|
||||||
Camera.Frame.ImageBufferSize = frameSize;
|
Camera.Frame.ImageBufferSize = frameSize;
|
||||||
Camera.Frame.ImageBuffer = grayframe->imageData;
|
Camera.Frame.ImageBuffer = grayframe->imageData;
|
||||||
}
|
}
|
||||||
else if (strcmp(pixelFormat, "Mono16")==0) {
|
else if (strcmp(pixelFormat, "Mono16")==0) {
|
||||||
grayframe = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_16U, 1);
|
grayframe = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_16U, 1);
|
||||||
grayframe->widthStep = (int)frameWidth;
|
grayframe->widthStep = (int)frameWidth;
|
||||||
frame = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_16U, 3);
|
frame = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_16U, 3);
|
||||||
frame->widthStep = (int)frameWidth*3;
|
frame->widthStep = (int)frameWidth*3;
|
||||||
Camera.Frame.ImageBufferSize = frameSize;
|
Camera.Frame.ImageBufferSize = frameSize;
|
||||||
Camera.Frame.ImageBuffer = grayframe->imageData;
|
Camera.Frame.ImageBuffer = grayframe->imageData;
|
||||||
}
|
}
|
||||||
else if (strcmp(pixelFormat, "Bgr24")==0) {
|
else if (strcmp(pixelFormat, "Bgr24")==0) {
|
||||||
frame = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 3);
|
frame = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 3);
|
||||||
frame->widthStep = (int)frameWidth*3;
|
frame->widthStep = (int)frameWidth*3;
|
||||||
Camera.Frame.ImageBufferSize = frameSize;
|
Camera.Frame.ImageBufferSize = frameSize;
|
||||||
Camera.Frame.ImageBuffer = frame->imageData;
|
Camera.Frame.ImageBuffer = frame->imageData;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
// Start the camera
|
// Start the camera
|
||||||
PvCaptureStart(Camera.Handle);
|
PvCaptureStart(Camera.Handle);
|
||||||
|
|
||||||
@ -226,19 +234,19 @@ bool CvCaptureCAM_PvAPI::open( int index )
|
|||||||
fprintf(stderr,"Could not set Prosilica Acquisition Mode\n");
|
fprintf(stderr,"Could not set Prosilica Acquisition Mode\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(PvCommandRun(Camera.Handle, "AcquisitionStart")!= ePvErrSuccess)
|
if(PvCommandRun(Camera.Handle, "AcquisitionStart")!= ePvErrSuccess)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Could not start Prosilica acquisition\n");
|
fprintf(stderr,"Could not start Prosilica acquisition\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(PvAttrEnumSet(Camera.Handle, "FrameStartTriggerMode", "Freerun")!= ePvErrSuccess)
|
if(PvAttrEnumSet(Camera.Handle, "FrameStartTriggerMode", "Freerun")!= ePvErrSuccess)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Error setting Prosilica trigger to \"Freerun\"");
|
fprintf(stderr,"Error setting Prosilica trigger to \"Freerun\"");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
fprintf(stderr,"Error cannot open camera\n");
|
fprintf(stderr,"Error cannot open camera\n");
|
||||||
@ -248,8 +256,8 @@ bool CvCaptureCAM_PvAPI::open( int index )
|
|||||||
|
|
||||||
bool CvCaptureCAM_PvAPI::grabFrame()
|
bool CvCaptureCAM_PvAPI::grabFrame()
|
||||||
{
|
{
|
||||||
//if(Camera.Frame.Status != ePvErrUnplugged && Camera.Frame.Status != ePvErrCancelled)
|
//if(Camera.Frame.Status != ePvErrUnplugged && Camera.Frame.Status != ePvErrCancelled)
|
||||||
return PvCaptureQueueFrame(Camera.Handle, &(Camera.Frame), NULL) == ePvErrSuccess;
|
return PvCaptureQueueFrame(Camera.Handle, &(Camera.Frame), NULL) == ePvErrSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -257,13 +265,13 @@ IplImage* CvCaptureCAM_PvAPI::retrieveFrame(int)
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (PvCaptureWaitForFrameDone(Camera.Handle, &(Camera.Frame), 1000) == ePvErrSuccess) {
|
if (PvCaptureWaitForFrameDone(Camera.Handle, &(Camera.Frame), 1000) == ePvErrSuccess) {
|
||||||
if (!monocrome) {
|
if (!monocrome) {
|
||||||
cvMerge(grayframe,grayframe,grayframe,NULL,frame);
|
cvMerge(grayframe,grayframe,grayframe,NULL,frame);
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
return grayframe;
|
return grayframe;
|
||||||
}
|
}
|
||||||
else return NULL;
|
else return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
double CvCaptureCAM_PvAPI::getProperty( int property_id )
|
double CvCaptureCAM_PvAPI::getProperty( int property_id )
|
||||||
@ -279,26 +287,26 @@ double CvCaptureCAM_PvAPI::getProperty( int property_id )
|
|||||||
PvAttrUint32Get(Camera.Handle, "Height", &nTemp);
|
PvAttrUint32Get(Camera.Handle, "Height", &nTemp);
|
||||||
return (double)nTemp;
|
return (double)nTemp;
|
||||||
case CV_CAP_PROP_EXPOSURE:
|
case CV_CAP_PROP_EXPOSURE:
|
||||||
PvAttrUint32Get(Camera.Handle,"ExposureValue",&nTemp);
|
PvAttrUint32Get(Camera.Handle,"ExposureValue",&nTemp);
|
||||||
return (double)nTemp;
|
return (double)nTemp;
|
||||||
case CV_CAP_PROP_FPS:
|
case CV_CAP_PROP_FPS:
|
||||||
tPvFloat32 nfTemp;
|
tPvFloat32 nfTemp;
|
||||||
PvAttrFloat32Get(Camera.Handle, "StatFrameRate", &nfTemp);
|
PvAttrFloat32Get(Camera.Handle, "StatFrameRate", &nfTemp);
|
||||||
return (double)nfTemp;
|
return (double)nfTemp;
|
||||||
case CV_CAP_PROP_PVAPI_MULTICASTIP:
|
case CV_CAP_PROP_PVAPI_MULTICASTIP:
|
||||||
char mEnable[2];
|
char mEnable[2];
|
||||||
char mIp[11];
|
char mIp[11];
|
||||||
PvAttrEnumGet(Camera.Handle,"MulticastEnable",mEnable,sizeof(mEnable),NULL);
|
PvAttrEnumGet(Camera.Handle,"MulticastEnable",mEnable,sizeof(mEnable),NULL);
|
||||||
if (strcmp(mEnable, "Off") == 0) {
|
if (strcmp(mEnable, "Off") == 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
long int ip;
|
long int ip;
|
||||||
int a,b,c,d;
|
int a,b,c,d;
|
||||||
PvAttrStringGet(Camera.Handle, "MulticastIPAddress",mIp,sizeof(mIp),NULL);
|
PvAttrStringGet(Camera.Handle, "MulticastIPAddress",mIp,sizeof(mIp),NULL);
|
||||||
sscanf(mIp, "%d.%d.%d.%d", &a, &b, &c, &d); ip = ((a*256 + b)*256 + c)*256 + d;
|
sscanf(mIp, "%d.%d.%d.%d", &a, &b, &c, &d); ip = ((a*256 + b)*256 + c)*256 + d;
|
||||||
return (double)ip;
|
return (double)ip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1.0;
|
return -1.0;
|
||||||
}
|
}
|
||||||
@ -317,38 +325,38 @@ bool CvCaptureCAM_PvAPI::setProperty( int property_id, double value )
|
|||||||
*/
|
*/
|
||||||
case CV_CAP_PROP_MONOCROME:
|
case CV_CAP_PROP_MONOCROME:
|
||||||
if (value==1) {
|
if (value==1) {
|
||||||
char pixelFormat[256];
|
char pixelFormat[256];
|
||||||
PvAttrEnumGet(Camera.Handle, "PixelFormat", pixelFormat,256,NULL);
|
PvAttrEnumGet(Camera.Handle, "PixelFormat", pixelFormat,256,NULL);
|
||||||
if ((strcmp(pixelFormat, "Mono8")==0) || strcmp(pixelFormat, "Mono16")==0) {
|
if ((strcmp(pixelFormat, "Mono8")==0) || strcmp(pixelFormat, "Mono16")==0) {
|
||||||
monocrome=true;
|
monocrome=true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
monocrome=false;
|
monocrome=false;
|
||||||
break;
|
break;
|
||||||
case CV_CAP_PROP_EXPOSURE:
|
case CV_CAP_PROP_EXPOSURE:
|
||||||
if ((PvAttrUint32Set(Camera.Handle,"ExposureValue",(tPvUint32)value)==ePvErrSuccess))
|
if ((PvAttrUint32Set(Camera.Handle,"ExposureValue",(tPvUint32)value)==ePvErrSuccess))
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
case CV_CAP_PROP_PVAPI_MULTICASTIP:
|
case CV_CAP_PROP_PVAPI_MULTICASTIP:
|
||||||
|
|
||||||
if (value==-1) {
|
if (value==-1) {
|
||||||
if ((PvAttrEnumSet(Camera.Handle,"MulticastEnable", "Off")==ePvErrSuccess))
|
if ((PvAttrEnumSet(Camera.Handle,"MulticastEnable", "Off")==ePvErrSuccess))
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::string ip=cv::format("%d.%d.%d.%d", ((int)value>>24)&255, ((int)value>>16)&255, ((int)value>>8)&255, (int)value&255);
|
std::string ip=cv::format("%d.%d.%d.%d", ((int)value>>24)&255, ((int)value>>16)&255, ((int)value>>8)&255, (int)value&255);
|
||||||
if ((PvAttrEnumSet(Camera.Handle,"MulticastEnable", "On")==ePvErrSuccess) &&
|
if ((PvAttrEnumSet(Camera.Handle,"MulticastEnable", "On")==ePvErrSuccess) &&
|
||||||
(PvAttrStringSet(Camera.Handle, "MulticastIPAddress", ip.c_str())==ePvErrSuccess))
|
(PvAttrStringSet(Camera.Handle, "MulticastIPAddress", ip.c_str())==ePvErrSuccess))
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -366,9 +374,4 @@ CvCapture* cvCreateCameraCapture_PvAPI( int index )
|
|||||||
delete capture;
|
delete capture;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma comment(lib, "PvAPI.lib")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user