mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
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:
@@ -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,15 +219,9 @@ 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;
|
||||
return frame;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user