USB Camera Control Settings Issue (OSX - W7)

asked 2013-06-27 22:22:22 -0500

sgbzona gravatar image

updated 2013-06-27 22:34:13 -0500

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 ...
(more)
edit retag flag offensive close merge delete