Merge pull request #3804 from polarfuchs99:master

pull/3836/head
Vadim Pisarevsky 10 years ago
commit 903f10c237
  1. 2
      modules/java/generator/gen_java.py
  2. 17
      modules/videoio/include/opencv2/videoio.hpp
  3. 2
      modules/videoio/include/opencv2/videoio/videoio_c.h
  4. 6
      modules/videoio/src/cap_dshow.cpp
  5. 140
      modules/videoio/src/cap_pvapi.cpp

@ -75,7 +75,7 @@ const_ignore_list = (
"CV_CAP_PROP_CONVERT_RGB", "CV_CAP_PROP_CONVERT_RGB",
"CV_CAP_PROP_WHITE_BALANCE_BLUE_U", "CV_CAP_PROP_WHITE_BALANCE_BLUE_U",
"CV_CAP_PROP_RECTIFICATION", "CV_CAP_PROP_RECTIFICATION",
"CV_CAP_PROP_MONOCROME", "CV_CAP_PROP_MONOCHROME",
"CV_CAP_PROP_SHARPNESS", "CV_CAP_PROP_SHARPNESS",
"CV_CAP_PROP_AUTO_EXPOSURE", "CV_CAP_PROP_AUTO_EXPOSURE",
"CV_CAP_PROP_GAMMA", "CV_CAP_PROP_GAMMA",

@ -110,8 +110,7 @@ enum { CAP_PROP_POS_MSEC =0,
CAP_PROP_CONVERT_RGB =16, CAP_PROP_CONVERT_RGB =16,
CAP_PROP_WHITE_BALANCE_BLUE_U =17, CAP_PROP_WHITE_BALANCE_BLUE_U =17,
CAP_PROP_RECTIFICATION =18, CAP_PROP_RECTIFICATION =18,
CAP_PROP_MONOCROME =19, CAP_PROP_MONOCHROME =19,
CAP_PROP_MONOCHROME =CAP_PROP_MONOCROME,
CAP_PROP_SHARPNESS =20, CAP_PROP_SHARPNESS =20,
CAP_PROP_AUTO_EXPOSURE =21, // DC1394: exposure control done by camera, user can adjust refernce level using this feature CAP_PROP_AUTO_EXPOSURE =21, // DC1394: exposure control done by camera, user can adjust refernce level using this feature
CAP_PROP_GAMMA =22, CAP_PROP_GAMMA =22,
@ -217,7 +216,8 @@ enum { CAP_PROP_PVAPI_MULTICASTIP = 300, // ip for anable multicast ma
CAP_PROP_PVAPI_DECIMATIONHORIZONTAL = 302, // Horizontal sub-sampling of the image CAP_PROP_PVAPI_DECIMATIONHORIZONTAL = 302, // Horizontal sub-sampling of the image
CAP_PROP_PVAPI_DECIMATIONVERTICAL = 303, // Vertical sub-sampling of the image CAP_PROP_PVAPI_DECIMATIONVERTICAL = 303, // Vertical sub-sampling of the image
CAP_PROP_PVAPI_BINNINGX = 304, // Horizontal binning factor CAP_PROP_PVAPI_BINNINGX = 304, // Horizontal binning factor
CAP_PROP_PVAPI_BINNINGY = 305 // Vertical binning factor CAP_PROP_PVAPI_BINNINGY = 305, // Vertical binning factor
CAP_PROP_PVAPI_PIXELFORMAT = 306 // Pixel format
}; };
// PVAPI: FrameStartTriggerMode // PVAPI: FrameStartTriggerMode
@ -235,6 +235,17 @@ enum { CAP_PVAPI_DECIMATION_OFF = 1, // Off
CAP_PVAPI_DECIMATION_2OUTOF16 = 8 // 2 out of 16 decimation CAP_PVAPI_DECIMATION_2OUTOF16 = 8 // 2 out of 16 decimation
}; };
// PVAPI: PixelFormat
enum { CAP_PVAPI_PIXELFORMAT_MONO8 = 1, // Mono8
CAP_PVAPI_PIXELFORMAT_MONO16 = 2, // Mono16
CAP_PVAPI_PIXELFORMAT_BAYER8 = 3, // Bayer8
CAP_PVAPI_PIXELFORMAT_BAYER16 = 4, // Bayer16
CAP_PVAPI_PIXELFORMAT_RGB24 = 5, // Rgb24
CAP_PVAPI_PIXELFORMAT_BGR24 = 6, // Bgr24
CAP_PVAPI_PIXELFORMAT_RGBA32 = 7, // Rgba32
CAP_PVAPI_PIXELFORMAT_BGRA32 = 8, // Bgra32
};
// Properties of cameras available through XIMEA SDK interface // Properties of cameras available through XIMEA SDK interface
enum { CAP_PROP_XI_DOWNSAMPLING = 400, // Change image resolution by binning or skipping. enum { CAP_PROP_XI_DOWNSAMPLING = 400, // Change image resolution by binning or skipping.
CAP_PROP_XI_DATA_FORMAT = 401, // Output data format. CAP_PROP_XI_DATA_FORMAT = 401, // Output data format.

@ -160,7 +160,6 @@ enum
CV_CAP_PROP_CONVERT_RGB =16, CV_CAP_PROP_CONVERT_RGB =16,
CV_CAP_PROP_WHITE_BALANCE_BLUE_U =17, CV_CAP_PROP_WHITE_BALANCE_BLUE_U =17,
CV_CAP_PROP_RECTIFICATION =18, CV_CAP_PROP_RECTIFICATION =18,
CV_CAP_PROP_MONOCROME =19,
CV_CAP_PROP_MONOCHROME =19, CV_CAP_PROP_MONOCHROME =19,
CV_CAP_PROP_SHARPNESS =20, CV_CAP_PROP_SHARPNESS =20,
CV_CAP_PROP_AUTO_EXPOSURE =21, // exposure control done by camera, CV_CAP_PROP_AUTO_EXPOSURE =21, // exposure control done by camera,
@ -227,6 +226,7 @@ enum
CV_CAP_PROP_PVAPI_DECIMATIONVERTICAL = 303, // Vertical sub-sampling of the image CV_CAP_PROP_PVAPI_DECIMATIONVERTICAL = 303, // Vertical sub-sampling of the image
CV_CAP_PROP_PVAPI_BINNINGX = 304, // Horizontal binning factor CV_CAP_PROP_PVAPI_BINNINGX = 304, // Horizontal binning factor
CV_CAP_PROP_PVAPI_BINNINGY = 305, // Vertical binning factor CV_CAP_PROP_PVAPI_BINNINGY = 305, // Vertical binning factor
CV_CAP_PROP_PVAPI_PIXELFORMAT = 306, // Pixel format
// Properties of cameras available through XIMEA SDK interface // Properties of cameras available through XIMEA SDK interface
CV_CAP_PROP_XI_DOWNSAMPLING = 400, // Change image resolution by binning or skipping. CV_CAP_PROP_XI_DOWNSAMPLING = 400, // Change image resolution by binning or skipping.

@ -2257,7 +2257,7 @@ int videoInput::getVideoPropertyFromCV(int cv_property){
case CV_CAP_PROP_GAMMA: case CV_CAP_PROP_GAMMA:
return VideoProcAmp_Gamma; return VideoProcAmp_Gamma;
case CV_CAP_PROP_MONOCROME: case CV_CAP_PROP_MONOCHROME:
return VideoProcAmp_ColorEnable; return VideoProcAmp_ColorEnable;
case CV_CAP_PROP_WHITE_BALANCE_BLUE_U: case CV_CAP_PROP_WHITE_BALANCE_BLUE_U:
@ -3170,7 +3170,7 @@ double VideoCapture_DShow::getProperty(int propIdx) const
case CV_CAP_PROP_SATURATION: case CV_CAP_PROP_SATURATION:
case CV_CAP_PROP_SHARPNESS: case CV_CAP_PROP_SHARPNESS:
case CV_CAP_PROP_GAMMA: case CV_CAP_PROP_GAMMA:
case CV_CAP_PROP_MONOCROME: case CV_CAP_PROP_MONOCHROME:
case CV_CAP_PROP_WHITE_BALANCE_BLUE_U: case CV_CAP_PROP_WHITE_BALANCE_BLUE_U:
case CV_CAP_PROP_BACKLIGHT: case CV_CAP_PROP_BACKLIGHT:
case CV_CAP_PROP_GAIN: case CV_CAP_PROP_GAIN:
@ -3273,7 +3273,7 @@ bool VideoCapture_DShow::setProperty(int propIdx, double propVal)
case CV_CAP_PROP_SATURATION: case CV_CAP_PROP_SATURATION:
case CV_CAP_PROP_SHARPNESS: case CV_CAP_PROP_SHARPNESS:
case CV_CAP_PROP_GAMMA: case CV_CAP_PROP_GAMMA:
case CV_CAP_PROP_MONOCROME: case CV_CAP_PROP_MONOCHROME:
case CV_CAP_PROP_WHITE_BALANCE_BLUE_U: case CV_CAP_PROP_WHITE_BALANCE_BLUE_U:
case CV_CAP_PROP_BACKLIGHT: case CV_CAP_PROP_BACKLIGHT:
case CV_CAP_PROP_GAIN: case CV_CAP_PROP_GAIN:

@ -60,6 +60,7 @@
#ifdef WIN32 #ifdef WIN32
# include <io.h> # include <io.h>
#else #else
# include <time.h>
# include <unistd.h> # include <unistd.h>
#endif #endif
@ -106,18 +107,14 @@ protected:
} tCamera; } tCamera;
IplImage *frame; IplImage *frame;
IplImage *grayframe;
tCamera Camera; tCamera Camera;
tPvErr Errcode; tPvErr Errcode;
bool monocrome;
}; };
CvCaptureCAM_PvAPI::CvCaptureCAM_PvAPI() CvCaptureCAM_PvAPI::CvCaptureCAM_PvAPI()
{ {
monocrome=false;
frame = NULL; frame = NULL;
grayframe = NULL;
memset(&this->Camera, 0, sizeof(this->Camera)); memset(&this->Camera, 0, sizeof(this->Camera));
} }
@ -190,13 +187,6 @@ bool CvCaptureCAM_PvAPI::open( int index )
tPvUint32 frameWidth, frameHeight; tPvUint32 frameWidth, frameHeight;
unsigned long maxSize; unsigned long maxSize;
// By Default, try to set the pixel format to Mono8. This can be changed later
// via calls to setProperty. Some colour cameras (i.e. the Manta line) have a default
// image mode of Bayer8, which is currently unsupported, so Mono8 is a safe bet for
// startup.
monocrome = (PvAttrEnumSet(Camera.Handle, "PixelFormat", "Mono8") == ePvErrSuccess);
PvAttrUint32Get(Camera.Handle, "Width", &frameWidth); PvAttrUint32Get(Camera.Handle, "Width", &frameWidth);
PvAttrUint32Get(Camera.Handle, "Height", &frameHeight); PvAttrUint32Get(Camera.Handle, "Height", &frameHeight);
@ -229,15 +219,9 @@ bool CvCaptureCAM_PvAPI::grabFrame()
IplImage* CvCaptureCAM_PvAPI::retrieveFrame(int) IplImage* CvCaptureCAM_PvAPI::retrieveFrame(int)
{ {
if (PvCaptureWaitForFrameDone(Camera.Handle, &(Camera.Frame), 1000) == ePvErrSuccess) if (PvCaptureWaitForFrameDone(Camera.Handle, &(Camera.Frame), 1000) == ePvErrSuccess)
{ {
if (!monocrome) return frame;
{
cvMerge(grayframe,grayframe,grayframe,NULL,frame);
return frame;
}
return grayframe;
} }
else return NULL; else return NULL;
} }
@ -254,11 +238,6 @@ double CvCaptureCAM_PvAPI::getProperty( int property_id ) const
case CV_CAP_PROP_FRAME_HEIGHT: case CV_CAP_PROP_FRAME_HEIGHT:
PvAttrUint32Get(Camera.Handle, "Height", &nTemp); PvAttrUint32Get(Camera.Handle, "Height", &nTemp);
return (double)nTemp; return (double)nTemp;
case CV_CAP_PROP_MONOCROME:
if (monocrome)
return 1;
else
return 0;
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;
@ -312,6 +291,25 @@ double CvCaptureCAM_PvAPI::getProperty( int property_id ) const
case CV_CAP_PROP_PVAPI_BINNINGY: case CV_CAP_PROP_PVAPI_BINNINGY:
PvAttrUint32Get(Camera.Handle,"BinningY",&nTemp); PvAttrUint32Get(Camera.Handle,"BinningY",&nTemp);
return (double)nTemp; return (double)nTemp;
case CV_CAP_PROP_PVAPI_PIXELFORMAT:
char pixelFormat[256];
PvAttrEnumGet(Camera.Handle, "PixelFormat", pixelFormat,256,NULL);
if (strcmp(pixelFormat, "Mono8")==0)
return 1.0;
else if (strcmp(pixelFormat, "Mono16")==0)
return 2.0;
else if (strcmp(pixelFormat, "Bayer8")==0)
return 3.0;
else if (strcmp(pixelFormat, "Bayer16")==0)
return 4.0;
else if (strcmp(pixelFormat, "Rgb24")==0)
return 5.0;
else if (strcmp(pixelFormat, "Bgr24")==0)
return 6.0;
else if (strcmp(pixelFormat, "Rgba32")==0)
return 7.0;
else if (strcmp(pixelFormat, "Bgra32")==0)
return 8.0;
} }
return -1.0; return -1.0;
} }
@ -359,21 +357,6 @@ bool CvCaptureCAM_PvAPI::setProperty( int property_id, double value )
break; break;
} }
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;
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;
@ -449,6 +432,51 @@ bool CvCaptureCAM_PvAPI::setProperty( int property_id, double value )
break; break;
else else
return false; return false;
case CV_CAP_PROP_PVAPI_PIXELFORMAT:
{
cv::String pixelFormat;
if (value==1)
pixelFormat = "Mono8";
else if (value==2)
pixelFormat = "Mono16";
else if (value==3)
pixelFormat = "Bayer8";
else if (value==4)
pixelFormat = "Bayer16";
else if (value==5)
pixelFormat = "Rgb24";
else if (value==6)
pixelFormat = "Bgr24";
else if (value==7)
pixelFormat = "Rgba32";
else if (value==8)
pixelFormat = "Bgra32";
else
return false;
if ((PvAttrEnumSet(Camera.Handle,"PixelFormat", pixelFormat.c_str())==ePvErrSuccess))
{
tPvUint32 currWidth;
tPvUint32 currHeight;
PvAttrUint32Get(Camera.Handle, "Width", &currWidth);
PvAttrUint32Get(Camera.Handle, "Height", &currHeight);
stopCapture();
// Reallocate Frames
if (!resizeCaptureFrame(currWidth, currHeight))
{
startCapture();
return false;
}
startCapture();
return true;
}
else
return false;
}
default: default:
return false; return false;
} }
@ -495,13 +523,6 @@ bool CvCaptureCAM_PvAPI::resizeCaptureFrame (int frameWidth, int frameHeight)
tPvUint32 sensorHeight; tPvUint32 sensorHeight;
tPvUint32 sensorWidth; tPvUint32 sensorWidth;
if (grayframe)
{
cvReleaseImage(&grayframe);
grayframe = NULL;
}
if (frame) if (frame)
{ {
cvReleaseImage(&frame); cvReleaseImage(&frame);
@ -544,31 +565,34 @@ bool CvCaptureCAM_PvAPI::resizeCaptureFrame (int frameWidth, int frameHeight)
PvAttrUint32Get(Camera.Handle, "TotalBytesPerFrame", &frameSize); PvAttrUint32Get(Camera.Handle, "TotalBytesPerFrame", &frameSize);
if (strcmp(pixelFormat, "Mono8")==0) if ( (strcmp(pixelFormat, "Mono8")==0) || (strcmp(pixelFormat, "Bayer8")==0) )
{ {
grayframe = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 1); frame = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 1);
grayframe->widthStep = (int)frameWidth; frame->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.ImageBufferSize = frameSize;
Camera.Frame.ImageBuffer = grayframe->imageData; Camera.Frame.ImageBuffer = frame->imageData;
} }
else if (strcmp(pixelFormat, "Mono16")==0) else if ( (strcmp(pixelFormat, "Mono16")==0) || (strcmp(pixelFormat, "Bayer16")==0) )
{ {
grayframe = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_16U, 1); frame = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_16U, 1);
grayframe->widthStep = (int)frameWidth; frame->widthStep = (int)frameWidth*2;
frame = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_16U, 3);
frame->widthStep = (int)frameWidth*3;
Camera.Frame.ImageBufferSize = frameSize; Camera.Frame.ImageBufferSize = frameSize;
Camera.Frame.ImageBuffer = grayframe->imageData; Camera.Frame.ImageBuffer = frame->imageData;
} }
else if (strcmp(pixelFormat, "Bgr24")==0) else if ( (strcmp(pixelFormat, "Rgb24")==0) || (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 if ( (strcmp(pixelFormat, "Rgba32")==0) || (strcmp(pixelFormat, "Bgra32")==0) )
{
frame = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 4);
frame->widthStep = (int)frameWidth*4;
Camera.Frame.ImageBufferSize = frameSize;
Camera.Frame.ImageBuffer = frame->imageData;
}
else else
return false; return false;

Loading…
Cancel
Save