Changes to be committed:

(use "git reset HEAD <file>..." to unstage)

	modified:   modules/java/generator/gen_java.py
	modified:   modules/videoio/include/opencv2/videoio.hpp
	modified:   modules/videoio/include/opencv2/videoio/videoio_c.h
	modified:   modules/videoio/src/cap_dshow.cpp
	modified:   modules/videoio/src/cap_pvapi.cpp

Following changes have been made:
1. Some minor bugs have been removed.
2. In the PvAPI module the option CAP_PROP_MONOCROME has been removed because
   this option does not make sense and causes an error if a color camera is used.
3. Instead the new option CAP_PROP_PVAPI_PIXELFORMAT has been added which allows
   to activate the different pixel formats (color modes) of an AVT camera.
4. Since there were two identical defines
   CAP_PROP_MONOCROME = 19
   CAP_PROP_MONOCHROME = 19
   which were also used in the other module DSHOW, the first one with an orthographic
   error has been removed in favor of the second one.
This commit is contained in:
Prof. Dr. Rudolf Haussmann 2015-03-07 12:53:32 +01:00
parent d3b74cdcb2
commit 9f1eb70dbc
5 changed files with 104 additions and 69 deletions

View File

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

View File

@ -110,8 +110,7 @@ enum { CAP_PROP_POS_MSEC =0,
CAP_PROP_CONVERT_RGB =16,
CAP_PROP_WHITE_BALANCE_BLUE_U =17,
CAP_PROP_RECTIFICATION =18,
CAP_PROP_MONOCROME =19,
CAP_PROP_MONOCHROME =CAP_PROP_MONOCROME,
CAP_PROP_MONOCHROME =19,
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_GAMMA =22,
@ -216,7 +215,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_DECIMATIONVERTICAL = 303, // Vertical sub-sampling of the image
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
@ -234,6 +234,17 @@ enum { CAP_PVAPI_DECIMATION_OFF = 1, // Off
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
enum { CAP_PROP_XI_DOWNSAMPLING = 400, // Change image resolution by binning or skipping.
CAP_PROP_XI_DATA_FORMAT = 401, // Output data format.

View File

@ -160,7 +160,6 @@ enum
CV_CAP_PROP_CONVERT_RGB =16,
CV_CAP_PROP_WHITE_BALANCE_BLUE_U =17,
CV_CAP_PROP_RECTIFICATION =18,
CV_CAP_PROP_MONOCROME =19,
CV_CAP_PROP_MONOCHROME =19,
CV_CAP_PROP_SHARPNESS =20,
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_BINNINGX = 304, // Horizontal 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
CV_CAP_PROP_XI_DOWNSAMPLING = 400, // Change image resolution by binning or skipping.

View File

@ -2257,7 +2257,7 @@ int videoInput::getVideoPropertyFromCV(int cv_property){
case CV_CAP_PROP_GAMMA:
return VideoProcAmp_Gamma;
case CV_CAP_PROP_MONOCROME:
case CV_CAP_PROP_MONOCHROME:
return VideoProcAmp_ColorEnable;
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_SHARPNESS:
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_BACKLIGHT:
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_SHARPNESS:
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_BACKLIGHT:
case CV_CAP_PROP_GAIN:

View File

@ -60,6 +60,7 @@
#ifdef WIN32
# include <io.h>
#else
# include <time.h>
# include <unistd.h>
#endif
@ -106,18 +107,14 @@ protected:
} tCamera;
IplImage *frame;
IplImage *grayframe;
tCamera Camera;
tPvErr Errcode;
bool monocrome;
};
CvCaptureCAM_PvAPI::CvCaptureCAM_PvAPI()
{
monocrome=false;
frame = NULL;
grayframe = NULL;
memset(&this->Camera, 0, sizeof(this->Camera));
}
@ -190,13 +187,6 @@ bool CvCaptureCAM_PvAPI::open( int index )
tPvUint32 frameWidth, frameHeight;
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, "Height", &frameHeight);
@ -229,16 +219,10 @@ bool CvCaptureCAM_PvAPI::grabFrame()
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;
}
@ -254,11 +238,6 @@ double CvCaptureCAM_PvAPI::getProperty( int property_id ) const
case CV_CAP_PROP_FRAME_HEIGHT:
PvAttrUint32Get(Camera.Handle, "Height", &nTemp);
return (double)nTemp;
case CV_CAP_PROP_MONOCROME:
if (monocrome)
return 1;
else
return 0;
case CV_CAP_PROP_EXPOSURE:
PvAttrUint32Get(Camera.Handle,"ExposureValue",&nTemp);
return (double)nTemp;
@ -312,6 +291,25 @@ double CvCaptureCAM_PvAPI::getProperty( int property_id ) const
case CV_CAP_PROP_PVAPI_BINNINGY:
PvAttrUint32Get(Camera.Handle,"BinningY",&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;
}
@ -359,21 +357,6 @@ bool CvCaptureCAM_PvAPI::setProperty( int property_id, double value )
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:
if ((PvAttrUint32Set(Camera.Handle,"ExposureValue",(tPvUint32)value)==ePvErrSuccess))
break;
@ -449,6 +432,51 @@ bool CvCaptureCAM_PvAPI::setProperty( int property_id, double value )
break;
else
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:
return false;
}
@ -495,13 +523,6 @@ bool CvCaptureCAM_PvAPI::resizeCaptureFrame (int frameWidth, int frameHeight)
tPvUint32 sensorHeight;
tPvUint32 sensorWidth;
if (grayframe)
{
cvReleaseImage(&grayframe);
grayframe = NULL;
}
if (frame)
{
cvReleaseImage(&frame);
@ -544,28 +565,31 @@ bool CvCaptureCAM_PvAPI::resizeCaptureFrame (int frameWidth, int frameHeight)
PvAttrUint32Get(Camera.Handle, "TotalBytesPerFrame", &frameSize);
if (strcmp(pixelFormat, "Mono8")==0)
if ( (strcmp(pixelFormat, "Mono8")==0) || (strcmp(pixelFormat, "Bayer8")==0) )
{
frame = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 1);
frame->widthStep = (int)frameWidth;
Camera.Frame.ImageBufferSize = frameSize;
Camera.Frame.ImageBuffer = frame->imageData;
}
else if ( (strcmp(pixelFormat, "Mono16")==0) || (strcmp(pixelFormat, "Bayer16")==0) )
{
frame = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_16U, 1);
frame->widthStep = (int)frameWidth*2;
Camera.Frame.ImageBufferSize = frameSize;
Camera.Frame.ImageBuffer = frame->imageData;
}
else if ( (strcmp(pixelFormat, "Rgb24")==0) || (strcmp(pixelFormat, "Bgr24")==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;
Camera.Frame.ImageBuffer = frame->imageData;
}
else if (strcmp(pixelFormat, "Mono16")==0)
else if ( (strcmp(pixelFormat, "Rgba32")==0) || (strcmp(pixelFormat, "Bgra32")==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;
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;
}