mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 14:13:15 +08:00
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)
|
||||
else()
|
||||
set(ENABLE_SOLUTION_FOLDERS0 OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# OpenCV build options
|
||||
# ===================================================
|
||||
@ -312,7 +312,7 @@ if(UNIX)
|
||||
include(cmake/OpenCVFindPkgConfig.cmake OPTIONAL)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckIncludeFile)
|
||||
|
||||
|
||||
if(NOT APPLE)
|
||||
CHECK_INCLUDE_FILE(alloca.h HAVE_ALLOCA_H)
|
||||
CHECK_FUNCTION_EXISTS(alloca HAVE_ALLOCA)
|
||||
@ -408,11 +408,32 @@ endif(WITH_UNICAP)
|
||||
ocv_clear_vars(HAVE_PVAPI)
|
||||
if(WITH_PVAPI)
|
||||
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")
|
||||
|
||||
if(PVAPI_INCLUDE_PATH)
|
||||
set(HAVE_PVAPI TRUE)
|
||||
endif()
|
||||
if(X86 AND NOT WIN32)
|
||||
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)
|
||||
|
||||
# --- Dc1394 ---
|
||||
@ -463,7 +484,7 @@ if(WITH_FFMPEG)
|
||||
CHECK_MODULE(libavformat HAVE_FFMPEG_FORMAT)
|
||||
CHECK_MODULE(libavutil HAVE_FFMPEG_UTIL)
|
||||
CHECK_MODULE(libswscale HAVE_FFMPEG_SWSCALE)
|
||||
|
||||
|
||||
CHECK_INCLUDE_FILE(libavformat/avformat.h HAVE_GENTOO_FFMPEG)
|
||||
CHECK_INCLUDE_FILE(ffmpeg/avformat.h 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})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
if(NOT CLP_FOUND)
|
||||
find_path(CLP_INCLUDE_PATH "coin"
|
||||
PATHS "/usr/local/include" "/usr/include" "/opt/include"
|
||||
@ -607,7 +628,7 @@ if(WITH_CLP)
|
||||
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} libClp libCoinUtils)
|
||||
endif()
|
||||
set(HAVE_CLP TRUE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif(WITH_CLP)
|
||||
|
||||
@ -623,7 +644,7 @@ include(cmake/OpenCVDetectPython.cmake REQUIRED)
|
||||
if(ANDROID)
|
||||
include(cmake/OpenCVDetectApacheAnt.cmake REQUIRED)
|
||||
include(cmake/OpenCVDetectAndroidSDK.cmake REQUIRED)
|
||||
|
||||
|
||||
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.")
|
||||
endif()
|
||||
|
@ -96,7 +96,7 @@ elseif(APPLE)
|
||||
list(APPEND HIGHGUI_LIBRARIES "-framework Cocoa")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND highgui_srcs src/cap_vfw.cpp src/cap_cmu.cpp src/cap_dshow.cpp)
|
||||
endif(WIN32)
|
||||
@ -157,19 +157,8 @@ endif(HAVE_FFMPEG)
|
||||
if(HAVE_PVAPI)
|
||||
add_definitions(-DHAVE_PVAPI)
|
||||
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_LIBRARIES ${HIGHGUI_LIBRARIES} PvAPI)
|
||||
list(APPEND HIGHGUI_LIBRARIES ${PVAPI_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(WITH_IMAGEIO)
|
||||
@ -241,11 +230,11 @@ if(WIN32 AND WITH_FFMPEG)
|
||||
if(MSVC64 OR MINGW64)
|
||||
set(FFMPEG_SUFFIX _64)
|
||||
endif()
|
||||
|
||||
|
||||
set(ffmpeg_bare_name "opencv_ffmpeg${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}")
|
||||
|
||||
|
||||
#if(MSVC AND CMAKE_VERSION VERSION_GREATER "2.8.2")
|
||||
# add_custom_command(TARGET ${the_module} POST_BUILD
|
||||
# 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}"
|
||||
COMMENT "Copying ${ffmpeg_path} to the output directory")
|
||||
endif()
|
||||
|
||||
|
||||
install(FILES "${ffmpeg_path}" DESTINATION bin COMPONENT main RENAME "${ffmpeg_bare_name_ver}")
|
||||
endif()
|
||||
|
||||
|
@ -57,7 +57,12 @@
|
||||
#endif
|
||||
|
||||
#include <PvApi.h>
|
||||
#include <unistd.h>
|
||||
#ifdef WIN32
|
||||
# include <io.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
//#include <arpa/inet.h>
|
||||
|
||||
@ -69,7 +74,7 @@ class CvCaptureCAM_PvAPI : public CvCapture
|
||||
{
|
||||
public:
|
||||
CvCaptureCAM_PvAPI();
|
||||
virtual ~CvCaptureCAM_PvAPI()
|
||||
virtual ~CvCaptureCAM_PvAPI()
|
||||
{
|
||||
close();
|
||||
}
|
||||
@ -80,52 +85,55 @@ public:
|
||||
virtual bool setProperty(int, double);
|
||||
virtual bool grabFrame();
|
||||
virtual IplImage* retrieveFrame(int);
|
||||
virtual int getCaptureDomain()
|
||||
virtual int getCaptureDomain()
|
||||
{
|
||||
return CV_CAP_PVAPI;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void Sleep(unsigned int time);
|
||||
#ifndef WIN32
|
||||
virtual void Sleep(unsigned int time);
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned long UID;
|
||||
tPvHandle Handle;
|
||||
tPvFrame Frame;
|
||||
|
||||
|
||||
} tCamera;
|
||||
|
||||
IplImage *frame;
|
||||
IplImage *grayframe;
|
||||
tCamera Camera;
|
||||
tPvErr Errcode;
|
||||
tCamera Camera;
|
||||
tPvErr Errcode;
|
||||
bool monocrome;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
CvCaptureCAM_PvAPI::CvCaptureCAM_PvAPI()
|
||||
{
|
||||
monocrome=false;
|
||||
monocrome=false;
|
||||
memset(&this->Camera, 0, sizeof(this->Camera));
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
void CvCaptureCAM_PvAPI::Sleep(unsigned int time)
|
||||
{
|
||||
struct timespec t,r;
|
||||
|
||||
|
||||
t.tv_sec = time / 1000;
|
||||
t.tv_nsec = (time % 1000) * 1000000;
|
||||
|
||||
t.tv_nsec = (time % 1000) * 1000000;
|
||||
|
||||
while(nanosleep(&t,&r)==-1)
|
||||
t = r;
|
||||
}
|
||||
#endif
|
||||
|
||||
void CvCaptureCAM_PvAPI::close()
|
||||
{
|
||||
// Stop the acquisition & free the camera
|
||||
PvCommandRun(Camera.Handle, "AcquisitionStop");
|
||||
PvCaptureEnd(Camera.Handle);
|
||||
// Stop the acquisition & free the camera
|
||||
PvCommandRun(Camera.Handle, "AcquisitionStop");
|
||||
PvCaptureEnd(Camera.Handle);
|
||||
PvCameraClose(Camera.Handle);
|
||||
PvUnInitialize();
|
||||
}
|
||||
@ -134,47 +142,47 @@ void CvCaptureCAM_PvAPI::close()
|
||||
bool CvCaptureCAM_PvAPI::open( int index )
|
||||
{
|
||||
tPvCameraInfo cameraList[MAX_CAMERAS];
|
||||
|
||||
|
||||
tPvCameraInfo camInfo;
|
||||
tPvIpSettings ipSettings;
|
||||
|
||||
|
||||
|
||||
if (PvInitialize()) {
|
||||
}
|
||||
//return false;
|
||||
|
||||
//return false;
|
||||
|
||||
Sleep(1000);
|
||||
|
||||
//close();
|
||||
|
||||
|
||||
int numCameras=PvCameraList(cameraList, MAX_CAMERAS, NULL);
|
||||
|
||||
if (numCameras <= 0 || index >= numCameras)
|
||||
return false;
|
||||
|
||||
Camera.UID = cameraList[index].UniqueId;
|
||||
Camera.UID = cameraList[index].UniqueId;
|
||||
|
||||
if (!PvCameraInfo(Camera.UID,&camInfo) && !PvCameraIpSettingsGet(Camera.UID,&ipSettings)) {
|
||||
/*
|
||||
struct in_addr addr;
|
||||
addr.s_addr = ipSettings.CurrentIpAddress;
|
||||
printf("Current address:\t%s\n",inet_ntoa(addr));
|
||||
addr.s_addr = ipSettings.CurrentIpSubnet;
|
||||
printf("Current subnet:\t\t%s\n",inet_ntoa(addr));
|
||||
addr.s_addr = ipSettings.CurrentIpGateway;
|
||||
printf("Current gateway:\t%s\n",inet_ntoa(addr));
|
||||
*/
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"ERROR: could not retrieve camera IP settings.\n");
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
struct in_addr addr;
|
||||
addr.s_addr = ipSettings.CurrentIpAddress;
|
||||
printf("Current address:\t%s\n",inet_ntoa(addr));
|
||||
addr.s_addr = ipSettings.CurrentIpSubnet;
|
||||
printf("Current subnet:\t\t%s\n",inet_ntoa(addr));
|
||||
addr.s_addr = ipSettings.CurrentIpGateway;
|
||||
printf("Current gateway:\t%s\n",inet_ntoa(addr));
|
||||
*/
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"ERROR: could not retrieve camera IP settings.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
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");
|
||||
if (Errcode != ePvErrSuccess)
|
||||
{
|
||||
@ -184,7 +192,7 @@ bool CvCaptureCAM_PvAPI::open( int index )
|
||||
*/
|
||||
tPvUint32 frameWidth, frameHeight, frameSize;
|
||||
unsigned long maxSize;
|
||||
char pixelFormat[256];
|
||||
char pixelFormat[256];
|
||||
PvAttrUint32Get(Camera.Handle, "TotalBytesPerFrame", &frameSize);
|
||||
PvAttrUint32Get(Camera.Handle, "Width", &frameWidth);
|
||||
PvAttrUint32Get(Camera.Handle, "Height", &frameHeight);
|
||||
@ -192,31 +200,31 @@ bool CvCaptureCAM_PvAPI::open( int index )
|
||||
maxSize = 8228;
|
||||
//PvAttrUint32Get(Camera.Handle,"PacketSize",&maxSize);
|
||||
if (PvCaptureAdjustPacketSize(Camera.Handle,maxSize)!=ePvErrSuccess)
|
||||
return false;
|
||||
return false;
|
||||
if (strcmp(pixelFormat, "Mono8")==0) {
|
||||
grayframe = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 1);
|
||||
grayframe->widthStep = (int)frameWidth;
|
||||
frame = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 3);
|
||||
frame->widthStep = (int)frameWidth*3;
|
||||
Camera.Frame.ImageBufferSize = frameSize;
|
||||
Camera.Frame.ImageBuffer = grayframe->imageData;
|
||||
}
|
||||
else if (strcmp(pixelFormat, "Mono16")==0) {
|
||||
grayframe = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_16U, 1);
|
||||
grayframe->widthStep = (int)frameWidth;
|
||||
frame = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_16U, 3);
|
||||
frame->widthStep = (int)frameWidth*3;
|
||||
Camera.Frame.ImageBufferSize = frameSize;
|
||||
Camera.Frame.ImageBuffer = grayframe->imageData;
|
||||
}
|
||||
else if (strcmp(pixelFormat, "Bgr24")==0) {
|
||||
frame = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 3);
|
||||
frame->widthStep = (int)frameWidth*3;
|
||||
Camera.Frame.ImageBufferSize = frameSize;
|
||||
Camera.Frame.ImageBuffer = frame->imageData;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
grayframe = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 1);
|
||||
grayframe->widthStep = (int)frameWidth;
|
||||
frame = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 3);
|
||||
frame->widthStep = (int)frameWidth*3;
|
||||
Camera.Frame.ImageBufferSize = frameSize;
|
||||
Camera.Frame.ImageBuffer = grayframe->imageData;
|
||||
}
|
||||
else if (strcmp(pixelFormat, "Mono16")==0) {
|
||||
grayframe = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_16U, 1);
|
||||
grayframe->widthStep = (int)frameWidth;
|
||||
frame = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_16U, 3);
|
||||
frame->widthStep = (int)frameWidth*3;
|
||||
Camera.Frame.ImageBufferSize = frameSize;
|
||||
Camera.Frame.ImageBuffer = grayframe->imageData;
|
||||
}
|
||||
else if (strcmp(pixelFormat, "Bgr24")==0) {
|
||||
frame = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 3);
|
||||
frame->widthStep = (int)frameWidth*3;
|
||||
Camera.Frame.ImageBufferSize = frameSize;
|
||||
Camera.Frame.ImageBuffer = frame->imageData;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
// Start the camera
|
||||
PvCaptureStart(Camera.Handle);
|
||||
|
||||
@ -226,19 +234,19 @@ bool CvCaptureCAM_PvAPI::open( int index )
|
||||
fprintf(stderr,"Could not set Prosilica Acquisition Mode\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(PvCommandRun(Camera.Handle, "AcquisitionStart")!= ePvErrSuccess)
|
||||
{
|
||||
fprintf(stderr,"Could not start Prosilica acquisition\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(PvAttrEnumSet(Camera.Handle, "FrameStartTriggerMode", "Freerun")!= ePvErrSuccess)
|
||||
{
|
||||
fprintf(stderr,"Error setting Prosilica trigger to \"Freerun\"");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
fprintf(stderr,"Error cannot open camera\n");
|
||||
@ -248,8 +256,8 @@ bool CvCaptureCAM_PvAPI::open( int index )
|
||||
|
||||
bool CvCaptureCAM_PvAPI::grabFrame()
|
||||
{
|
||||
//if(Camera.Frame.Status != ePvErrUnplugged && Camera.Frame.Status != ePvErrCancelled)
|
||||
return PvCaptureQueueFrame(Camera.Handle, &(Camera.Frame), NULL) == ePvErrSuccess;
|
||||
//if(Camera.Frame.Status != ePvErrUnplugged && Camera.Frame.Status != ePvErrCancelled)
|
||||
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 (!monocrome) {
|
||||
cvMerge(grayframe,grayframe,grayframe,NULL,frame);
|
||||
return frame;
|
||||
}
|
||||
return grayframe;
|
||||
}
|
||||
else return NULL;
|
||||
if (!monocrome) {
|
||||
cvMerge(grayframe,grayframe,grayframe,NULL,frame);
|
||||
return frame;
|
||||
}
|
||||
return grayframe;
|
||||
}
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
double CvCaptureCAM_PvAPI::getProperty( int property_id )
|
||||
@ -279,26 +287,26 @@ double CvCaptureCAM_PvAPI::getProperty( int property_id )
|
||||
PvAttrUint32Get(Camera.Handle, "Height", &nTemp);
|
||||
return (double)nTemp;
|
||||
case CV_CAP_PROP_EXPOSURE:
|
||||
PvAttrUint32Get(Camera.Handle,"ExposureValue",&nTemp);
|
||||
return (double)nTemp;
|
||||
PvAttrUint32Get(Camera.Handle,"ExposureValue",&nTemp);
|
||||
return (double)nTemp;
|
||||
case CV_CAP_PROP_FPS:
|
||||
tPvFloat32 nfTemp;
|
||||
tPvFloat32 nfTemp;
|
||||
PvAttrFloat32Get(Camera.Handle, "StatFrameRate", &nfTemp);
|
||||
return (double)nfTemp;
|
||||
case CV_CAP_PROP_PVAPI_MULTICASTIP:
|
||||
char mEnable[2];
|
||||
char mIp[11];
|
||||
PvAttrEnumGet(Camera.Handle,"MulticastEnable",mEnable,sizeof(mEnable),NULL);
|
||||
if (strcmp(mEnable, "Off") == 0) {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
long int ip;
|
||||
int a,b,c,d;
|
||||
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;
|
||||
return (double)ip;
|
||||
}
|
||||
char mEnable[2];
|
||||
char mIp[11];
|
||||
PvAttrEnumGet(Camera.Handle,"MulticastEnable",mEnable,sizeof(mEnable),NULL);
|
||||
if (strcmp(mEnable, "Off") == 0) {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
long int ip;
|
||||
int a,b,c,d;
|
||||
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;
|
||||
return (double)ip;
|
||||
}
|
||||
}
|
||||
return -1.0;
|
||||
}
|
||||
@ -317,38 +325,38 @@ bool CvCaptureCAM_PvAPI::setProperty( int property_id, double value )
|
||||
*/
|
||||
case CV_CAP_PROP_MONOCROME:
|
||||
if (value==1) {
|
||||
char pixelFormat[256];
|
||||
PvAttrEnumGet(Camera.Handle, "PixelFormat", pixelFormat,256,NULL);
|
||||
if ((strcmp(pixelFormat, "Mono8")==0) || strcmp(pixelFormat, "Mono16")==0) {
|
||||
monocrome=true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
monocrome=false;
|
||||
break;
|
||||
char pixelFormat[256];
|
||||
PvAttrEnumGet(Camera.Handle, "PixelFormat", pixelFormat,256,NULL);
|
||||
if ((strcmp(pixelFormat, "Mono8")==0) || strcmp(pixelFormat, "Mono16")==0) {
|
||||
monocrome=true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
monocrome=false;
|
||||
break;
|
||||
case CV_CAP_PROP_EXPOSURE:
|
||||
if ((PvAttrUint32Set(Camera.Handle,"ExposureValue",(tPvUint32)value)==ePvErrSuccess))
|
||||
break;
|
||||
else
|
||||
return false;
|
||||
if ((PvAttrUint32Set(Camera.Handle,"ExposureValue",(tPvUint32)value)==ePvErrSuccess))
|
||||
break;
|
||||
else
|
||||
return false;
|
||||
case CV_CAP_PROP_PVAPI_MULTICASTIP:
|
||||
|
||||
if (value==-1) {
|
||||
if ((PvAttrEnumSet(Camera.Handle,"MulticastEnable", "Off")==ePvErrSuccess))
|
||||
break;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
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);
|
||||
if ((PvAttrEnumSet(Camera.Handle,"MulticastEnable", "On")==ePvErrSuccess) &&
|
||||
(PvAttrStringSet(Camera.Handle, "MulticastIPAddress", ip.c_str())==ePvErrSuccess))
|
||||
break;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value==-1) {
|
||||
if ((PvAttrEnumSet(Camera.Handle,"MulticastEnable", "Off")==ePvErrSuccess))
|
||||
break;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
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);
|
||||
if ((PvAttrEnumSet(Camera.Handle,"MulticastEnable", "On")==ePvErrSuccess) &&
|
||||
(PvAttrStringSet(Camera.Handle, "MulticastIPAddress", ip.c_str())==ePvErrSuccess))
|
||||
break;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -366,9 +374,4 @@ CvCapture* cvCreateCameraCapture_PvAPI( int index )
|
||||
delete capture;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "PvAPI.lib")
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user