Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

USB Control Settings Issue (OSX - W7)

Hello Forum!!

I'm writing because I have an strange issue with OCV.

First let me set the scenario.

I have compile openCV 2.4.4 for Windows 7 for VS Express 2010. Everything was ok. OCV working well.

I have compile openCV 2.4.4 for MacOsX 10.6.8 for XCode 3.2.6 Compilation was ok. OCV working well.

I have a USB 2.0 camera LI-0V5640 5MP, with 720p and 1080p resolution. I have write a test program like shown:

/*
 *  usb-ocv.cpp
 *  ocl_img2
 *
 *  Created by SGB on 03/06/13.
 *  Copyright 2013 __MyCompanyName__. All rights reserved.
 *
 */

#include <stdio.h>

#include <opencv2/opencv.hpp>

using namespace cv;

#include "usb-ocv.h"

#define cameraID 0 // 0, 1
#define width 1280 //1280;//1920;//320;
#define height 720 //720;//1080;//240; //720p. 1080p

int main (int argc, const char * argv[]) {

    VideoCapture Cam0;  

    Cam0.open(cameraID);

    //Cam0.set(<#int propId#>, <#double value#>);

    if (!Cam0.isOpened()) {
        printf("No se puede abrir Cam%i :( \n ", cameraID);
        return -1;
    }

    //--------------------------------------
    //propiedades de la camera

    int Cam0AE = Cam0.get(CV_CAP_PROP_AUTO_EXPOSURE);   
    printf("Cam%i AE: %s \n", cameraID, Cam0AE == 0 ? "NO" : "YES" );

    int Cam0BL = Cam0.get(CV_CAP_PROP_BACKLIGHT);   
    printf("Cam%i Back Light: %s \n",cameraID, Cam0BL == 0 ? "NO" : "YES");

    int Cam0BR = Cam0.get(CV_CAP_PROP_BRIGHTNESS);  
    printf("Cam%i Bright: %s \n",cameraID, Cam0BR == 0 ? "NO" : "YES");

    int Cam0C = Cam0.get(CV_CAP_PROP_CONTRAST); 
    printf("Cam%i Contrast: %s \n",cameraID, Cam0C == 0 ? "NO" : "YES");

    int Cam0GN = Cam0.get(CV_CAP_PROP_GAIN);    
    printf("Cam%i Gain: %s \n",cameraID, Cam0GN == 0 ? "NO" : "YES");

    int Cam0GM = Cam0.get(CV_CAP_PROP_GAMMA);   
    printf("Cam%i Gamma: %s \n",cameraID, Cam0GM == 0 ? "NO" : "YES");

    int Cam0HUE = Cam0.get(CV_CAP_PROP_HUE);    
    printf("Cam%i Hue: %s \n",cameraID, Cam0HUE == 0 ? "NO" : "YES");

    int Cam0M = Cam0.get(CV_CAP_PROP_MODE); 
    printf("Cam%i Mode: %s \n",cameraID, Cam0M == 0 ? "NO" : "YES");

    int Cam0MONO = Cam0.get(CV_CAP_PROP_MONOCROME); 
    printf("Cam%i Mono: %s \n",cameraID, Cam0MONO == 0 ? "NO" : "YES");

    int Cam0SH = Cam0.get(CV_CAP_PROP_SHARPNESS);   
    printf("Cam%i Sharpness: %s \n",cameraID, Cam0SH == 0 ? "NO" : "YES");

    int Cam0SS = Cam0.get(CV_CAP_PROP_SETTINGS);    
    printf("Cam%i Settings: %s \n", cameraID, Cam0SS == 0 ? "NO" : "YES");

    int Cam0FPS = Cam0.get(CV_CAP_PROP_FPS);    
    printf("Cam%i fps: %s \n",cameraID, Cam0FPS == 0 ? "NO" : "YES");

    int Cam0SAT = Cam0.get(CV_CAP_PROP_SATURATION); 
    printf("Cam%i Saturation: %s \n", cameraID, Cam0SAT == 0 ? "NO" : "YES");

    int Cam0Exp = Cam0.get(CV_CAP_PROP_EXPOSURE);   
    printf("Cam%i Exposure: %s \n", cameraID, Cam0Exp == 0 ? "NO" : "YES");

    int Cam0FM = Cam0.get(CV_CAP_PROP_FOURCC);  
    printf("Cam%i PIM1/MJPG: %s \n", cameraID, Cam0FM == 0 ? "NO" : "YES");


    //--------------------------------------

    //*
    Cam0.set(CV_CAP_PROP_FRAME_WIDTH, width);
    Cam0.set(CV_CAP_PROP_FRAME_HEIGHT, height);

    Cam0.set(CV_CAP_PROP_SATURATION, 0); //0 - 50
    //Cam0.set(CV_CAP_PROP_EXPOSURE, 0);
     //*/

    int Cam0X = Cam0.get(CV_CAP_PROP_FRAME_WIDTH);  
    int Cam0Y = Cam0.get(CV_CAP_PROP_FRAME_HEIGHT); 

    printf("Cam%i x,y: %i %i \n", cameraID, Cam0X, Cam0Y);


    Mat obtImg1 (height, width, CV_8UC3);
    Mat buf1 (height, width, CV_8UC3);
    Mat buf2 (height, width, CV_8UC3);
    Mat temp1 (height, width, CV_8UC3);

    namedWindow("USB Cam", 0);

    int key = 0;

    while (key != 'q') {

        Cam0 >> temp1;
        temp1.copyTo(buf1);

        //------------------------
        //obtNeg2(buf1, buf2);
        //obtImg1 = buf2;

        obtImg1 = buf1;

        //------------------------

        imshow("USB Cam", obtImg1);

        key = cvWaitKey(1);

    }

    //Cam0.release();

    return 0;

}

I made some small adaptations to run on VSE 2010.

On W7 with VSE 2010 the camera shows the picture and the output on the console we see:

**

Cam1 AE: YES
Cam1 Back Light: NO 
Cam1 Bright: YES 
Cam1 Contrast: NO 
Cam1 Gain: YES 
Cam1 Gamma: YES 
Cam1 Hue: NO 
Cam1 Mode: NO 
Cam1 Mono: NO 
Cam1 Sharpness: YES 
Cam1 Settings: YES 
Cam1 fps: NO 
Cam1 Saturation: YES 
Cam1 Exposure: YES 
Cam1 PIM1/MJPG: YES 
Cam1 x,y: 1280 720

**

On OSX with XCode the camera shows the picture and the output on the console we see:

**

[Switching to process 59480]
Running…
Cam0 AE: NO 
Cam0 Back Light: NO 
Cam0 Bright: NO 
Cam0 Contrast: NO 
Cam0 Gain: NO 
Cam0 Gamma: NO 
Cam0 Hue: NO 
Cam0 Mode: NO 
Cam0 Mono: NO 
Cam0 Sharpness: NO 
Cam0 Settings: NO 
Cam0 fps: NO 
Cam0 Saturation: NO 
Cam0 Exposure: NO 
Cam0 PIM1/MJPG: NO 
Cam0 x,y: 1280 720 
Camera dropped frame!

**

Sadly, I can´t control the camera settings on OSX for some strange reason. I have compile again OCV on OSX with QT support and happens exactly the same :(

any ideas?

I will appreciate your help a lot.

USB Camera Control Settings Issue (OSX - W7)

Hello Forum!!

I'm writing because I have an strange issue with OCV.

First let me set the scenario.

I have compile openCV 2.4.4 for Windows 7 for VS Express 2010. Everything was ok. OCV working well.

I have compile openCV 2.4.4 for MacOsX 10.6.8 for XCode 3.2.6 Compilation was ok. OCV working well.

I have a USB 2.0 camera LI-0V5640 5MP, with 720p and 1080p resolution. I have write a test program like shown:

/*
 *  usb-ocv.cpp
 *  ocl_img2
 *
 *  Created by SGB on 03/06/13.
 *  Copyright 2013 __MyCompanyName__. All rights reserved.
 *
 */

#include <stdio.h>

#include <opencv2/opencv.hpp>

using namespace cv;

#include "usb-ocv.h"

#define cameraID 0 // 0, 1
#define width 1280 //1280;//1920;//320;
#define height 720 //720;//1080;//240; //720p. 1080p

int main (int argc, const char * argv[]) {

    VideoCapture Cam0;  

    Cam0.open(cameraID);

    //Cam0.set(<#int propId#>, <#double value#>);

    if (!Cam0.isOpened()) {
        printf("No se puede abrir Cam%i :( \n ", cameraID);
        return -1;
    }

    //--------------------------------------
    //propiedades de la camera

    int Cam0AE = Cam0.get(CV_CAP_PROP_AUTO_EXPOSURE);   
    printf("Cam%i AE: %s \n", cameraID, Cam0AE == 0 ? "NO" : "YES" );

    int Cam0BL = Cam0.get(CV_CAP_PROP_BACKLIGHT);   
    printf("Cam%i Back Light: %s \n",cameraID, Cam0BL == 0 ? "NO" : "YES");

    int Cam0BR = Cam0.get(CV_CAP_PROP_BRIGHTNESS);  
    printf("Cam%i Bright: %s \n",cameraID, Cam0BR == 0 ? "NO" : "YES");

    int Cam0C = Cam0.get(CV_CAP_PROP_CONTRAST); 
    printf("Cam%i Contrast: %s \n",cameraID, Cam0C == 0 ? "NO" : "YES");

    int Cam0GN = Cam0.get(CV_CAP_PROP_GAIN);    
    printf("Cam%i Gain: %s \n",cameraID, Cam0GN == 0 ? "NO" : "YES");

    int Cam0GM = Cam0.get(CV_CAP_PROP_GAMMA);   
    printf("Cam%i Gamma: %s \n",cameraID, Cam0GM == 0 ? "NO" : "YES");

    int Cam0HUE = Cam0.get(CV_CAP_PROP_HUE);    
    printf("Cam%i Hue: %s \n",cameraID, Cam0HUE == 0 ? "NO" : "YES");

    int Cam0M = Cam0.get(CV_CAP_PROP_MODE); 
    printf("Cam%i Mode: %s \n",cameraID, Cam0M == 0 ? "NO" : "YES");

    int Cam0MONO = Cam0.get(CV_CAP_PROP_MONOCROME); 
    printf("Cam%i Mono: %s \n",cameraID, Cam0MONO == 0 ? "NO" : "YES");

    int Cam0SH = Cam0.get(CV_CAP_PROP_SHARPNESS);   
    printf("Cam%i Sharpness: %s \n",cameraID, Cam0SH == 0 ? "NO" : "YES");

    int Cam0SS = Cam0.get(CV_CAP_PROP_SETTINGS);    
    printf("Cam%i Settings: %s \n", cameraID, Cam0SS == 0 ? "NO" : "YES");

    int Cam0FPS = Cam0.get(CV_CAP_PROP_FPS);    
    printf("Cam%i fps: %s \n",cameraID, Cam0FPS == 0 ? "NO" : "YES");

    int Cam0SAT = Cam0.get(CV_CAP_PROP_SATURATION); 
    printf("Cam%i Saturation: %s \n", cameraID, Cam0SAT == 0 ? "NO" : "YES");

    int Cam0Exp = Cam0.get(CV_CAP_PROP_EXPOSURE);   
    printf("Cam%i Exposure: %s \n", cameraID, Cam0Exp == 0 ? "NO" : "YES");

    int Cam0FM = Cam0.get(CV_CAP_PROP_FOURCC);  
    printf("Cam%i PIM1/MJPG: %s \n", cameraID, Cam0FM == 0 ? "NO" : "YES");


    //--------------------------------------

    //*
    Cam0.set(CV_CAP_PROP_FRAME_WIDTH, width);
    Cam0.set(CV_CAP_PROP_FRAME_HEIGHT, height);

    Cam0.set(CV_CAP_PROP_SATURATION, 0); //0 - 50
    //Cam0.set(CV_CAP_PROP_EXPOSURE, 0);
     //*/

    int Cam0X = Cam0.get(CV_CAP_PROP_FRAME_WIDTH);  
    int Cam0Y = Cam0.get(CV_CAP_PROP_FRAME_HEIGHT); 

    printf("Cam%i x,y: %i %i \n", cameraID, Cam0X, Cam0Y);


    Mat obtImg1 (height, width, CV_8UC3);
    Mat buf1 (height, width, CV_8UC3);
    Mat buf2 (height, width, CV_8UC3);
    Mat temp1 (height, width, CV_8UC3);

    namedWindow("USB Cam", 0);

    int key = 0;

    while (key != 'q') {

        Cam0 >> temp1;
        temp1.copyTo(buf1);

        //------------------------
        //obtNeg2(buf1, buf2);
        //obtImg1 = buf2;

        obtImg1 = buf1;

        //------------------------

        imshow("USB Cam", obtImg1);

        key = cvWaitKey(1);

    }

    //Cam0.release();

    return 0;

}

I made some small adaptations to run on VSE 2010.

On W7 with VSE 2010 the camera shows the picture and the output on the console we see:

**

Cam1 AE: YES
Cam1 Back Light: NO 
Cam1 Bright: YES 
Cam1 Contrast: NO 
Cam1 Gain: YES 
Cam1 Gamma: YES 
Cam1 Hue: NO 
Cam1 Mode: NO 
Cam1 Mono: NO 
Cam1 Sharpness: YES 
Cam1 Settings: YES 
Cam1 fps: NO 
Cam1 Saturation: YES 
Cam1 Exposure: YES 
Cam1 PIM1/MJPG: YES 
Cam1 x,y: 1280 720

**

On OSX with XCode the camera shows the picture and the output on the console we see:

**

[Switching to process 59480]
Running…
Cam0 AE: NO 
Cam0 Back Light: NO 
Cam0 Bright: NO 
Cam0 Contrast: NO 
Cam0 Gain: NO 
Cam0 Gamma: NO 
Cam0 Hue: NO 
Cam0 Mode: NO 
Cam0 Mono: NO 
Cam0 Sharpness: NO 
Cam0 Settings: NO 
Cam0 fps: NO 
Cam0 Saturation: NO 
Cam0 Exposure: NO 
Cam0 PIM1/MJPG: NO 
Cam0 x,y: 1280 720 
Camera dropped frame!

**

Sadly, I can´t control the camera settings on OSX for some strange reason. I have compile again OCV on OSX with QT support and happens exactly the same :(

any ideas?

I will appreciate your help a lot.