Some warning fix. Initial multicast get property support
authorStefano Fabri <no@email>
Thu, 9 Jun 2011 07:54:10 +0000 (07:54 +0000)
committerStefano Fabri <no@email>
Thu, 9 Jun 2011 07:54:10 +0000 (07:54 +0000)
modules/highgui/src/cap_pvapi.cpp

index 2663cd8..31518f8 100644 (file)
@@ -191,7 +191,7 @@ bool CvCaptureCAM_PvAPI::open( int index )
         //PvAttrUint32Get(Camera.Handle,"PacketSize",&maxSize);
         if (PvCaptureAdjustPacketSize(Camera.Handle,maxSize)!=ePvErrSuccess)
                        return false;
-        if (strncmp(pixelFormat, "Mono8",NULL)==0) {
+        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);
@@ -199,7 +199,7 @@ bool CvCaptureCAM_PvAPI::open( int index )
                                Camera.Frame.ImageBufferSize = frameSize;
                                Camera.Frame.ImageBuffer = grayframe->imageData;   
                }           
-               else if (strncmp(pixelFormat, "Mono16",NULL)==0) {
+               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);
@@ -207,7 +207,7 @@ bool CvCaptureCAM_PvAPI::open( int index )
                                Camera.Frame.ImageBufferSize = frameSize;
                                Camera.Frame.ImageBuffer = grayframe->imageData;
                }         
-               else if (strncmp(pixelFormat, "Bgr24",NULL)==0) {
+               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;
@@ -283,6 +283,20 @@ double CvCaptureCAM_PvAPI::getProperty( int property_id )
        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;
+       }
     }
     return -1.0;
 }
@@ -303,7 +317,7 @@ bool CvCaptureCAM_PvAPI::setProperty( int property_id, double value )
         if (value==1) {
                        char pixelFormat[256];
                        PvAttrEnumGet(Camera.Handle, "PixelFormat", pixelFormat,256,NULL);
-                       if ((strncmp(pixelFormat, "Mono8",NULL)==0) || strncmp(pixelFormat, "Mono16",NULL)==0) {
+                       if ((strcmp(pixelFormat, "Mono8")==0) || strcmp(pixelFormat, "Mono16")==0) {
                                monocrome=true;
                        }       
                        else