Ask Your Question

Jack_Wellem's profile - activity

2020-02-10 02:59:39 -0600 received badge  Notable Question (source)
2020-01-26 01:27:01 -0600 received badge  Notable Question (source)
2018-12-18 04:19:30 -0600 received badge  Popular Question (source)
2018-06-29 20:02:42 -0600 received badge  Popular Question (source)
2016-12-22 23:42:03 -0600 commented answer [OpenCV]How to detect and connect camera automatically

Thank you for your answer. But if I connect the device like this:not device --->connect device---->disconnect device-->connect device Could you give me some advices?

2016-12-14 01:58:58 -0600 asked a question [OpenCV]How to get the number of camera
  1. How to get the total number of camera?
  2. The following is my code, but i find that it will make the memory leak

    int CvCaptureCAM_DShow::getDeviceCount(){
    int deviceNumber = VI.listDevices(true);
    return deviceNumber;}
    
    
    int  cvGetDeviceCount_DShow(){
    CvCaptureCAM_DShow* capture = new CvCaptureCAM_DShow;
    
    int deviceCount = capture->getDeviceCount();
    
    delete capture;
    capture = NULL;
    
    return deviceCount;
    

    }

2016-12-09 19:19:56 -0600 commented answer [OpenCV]How to get the resolution of camera

I think this is a good idea to solve this question.Thank you.

2016-12-08 20:38:37 -0600 asked a question [OpenCV]How to get the resolution of camera

How to get the resolution of camera?Can somebody give me some suggestion. Only i can do is the following,but it takes too much time to get the resolution.

void GetResolution( const int& countOfCamera, resolution_t (&resoulationTemp)[MAX_RESOLUTION] ){
VideoCapture *pVideoCaptures[MAX_CAMERA] = {NULL};
bool ret1 = false;
bool ret2 = false;

for ( int j=0; j<countOfCamera; ++j ) {
    pVideoCaptures[j] = new VideoCapture(j);

    /*==========================================================================
    *If we don't do this, we will not open the Camera correctly
    ===========================================================================*/
    pVideoCaptures[j]->set( CV_CAP_PROP_FRAME_WIDTH, defaultResolution.width );
    pVideoCaptures[j]->set ( CV_CAP_PROP_FRAME_HEIGHT, defaultResolution.height );
}

for ( int i=0; i<MAX_RESOLUTION; ++i ) {

    for ( int j=0; j<countOfCamera; ++j ) {
        ret1 = pVideoCaptures[j]->set( CV_CAP_PROP_FRAME_WIDTH, resolutions[i].width );
        ret2 = pVideoCaptures[j]->set ( CV_CAP_PROP_FRAME_HEIGHT, resolutions[i].height );

        if ( !(ret1 && ret2) ) {                                //The resolution is not OK
            break;      //Check the next resolution
        } else if ( j == ( countOfCamera -1 ) ) {               //The resolution is OK for all camera,then store it.
            resoulationTemp[i].width = resolutions[i].width;
            resoulationTemp[i].height = resolutions[i].height;
        } else {
            //Do nothing
        }
    }

}

for ( int j=0; j<countOfCamera; ++j )                           //Release the memory
{
        pVideoCaptures[j]->release();

        delete pVideoCaptures[j];
        pVideoCaptures[j] = NULL;

}

}

2016-12-07 20:14:54 -0600 received badge  Scholar (source)
2016-12-06 20:24:03 -0600 asked a question [OpenCV]How to detect and connect camera automatically

How can i detect and connect camera automatically?

2016-11-25 01:56:58 -0600 received badge  Editor (source)
2016-11-25 01:27:09 -0600 received badge  Enthusiast
2016-11-24 21:41:43 -0600 asked a question [Opencv2.4.13]Two cameras hot plug, can't open the second camera
  1. working environment:Opencv2.4.13, VS2008, Camera(A and B)

  2. my question is: Connect A ----> Connect B: A,B both can be opened;Connect B ----> Connect A: B can be opened,but A can't.

  3. following is my code: when connect first camera:i use code VideoCapture videoCapture(0) when connect second camera:i use code VideoCapture videoCapture(1)
  4. B connect firstly then A.I check the opecv's code,i find that: when i call the videoCapture(1), the response of videoInput::getDevice is Camera B, not Camera A. It is so strange.
  5. Usb device number can be dynamic changed. When I connect B, the B's device NO. is 0. Then I connect A, B's device change to 1 and A's device NO. is 0. I think Opencv have not take this situation into account.Can somebody give me suggestion?
2016-11-21 20:13:25 -0600 commented question [OpenCV2.14.13]Can't open the second camera

Thank you, i have found that these camera use the same usb controller.If I want to open these cameras, i have to decrease the resolution. Below is the code that i can open the two camera:int _tmain(int argc, _TCHAR* argv[]) { VideoCapture camera0(1); camera0.set(CV_CAP_PROP_FRAME_WIDTH,432); camera0.set(CV_CAP_PROP_FRAME_HEIGHT,240); VideoCapture camera1(0); camera1.set(CV_CAP_PROP_FRAME_WIDTH,432); camera1.set(CV_CAP_PROP_FRAME_HEIGHT,240); return 0; }

2016-11-21 19:21:29 -0600 commented question [OpenCV2.14.13]Can't open the second camera

@Micka Thank you for your answer. Yes, i find that they use the same usb controller.

2016-11-21 04:02:39 -0600 asked a question [OpenCV2.14.13]Can't open the second camera
  1. The work environment is : OpenCV 2.4.13, VS2008, Two different kind of usb camera.
  2. I can't open the sencond camera when using the following code

    int _tmain(int argc, _TCHAR* argv[]){
    VideoCapture capture(0);
    if( !capture.isOpened() )
        std::cout << "Capture0 can't be opened\n" << std::endl;
    
    VideoCapture capture1(1);
    if( !capture1.isOpened() )
        std::cout << "Capture1 can't be opened\n" << std::endl;
    
    return 0;}
    
2016-11-21 00:55:08 -0600 asked a question [OpenCV 2.4.13]Only one camera can work currently

The Question is:

The work environment is : OpenCV 2.4.13, VS2008, Two different kind of usb camera.

Use the following code, I find that only one cammera can grap the frame.

The output is:

Searching for cameras IDs...

Testing driver CV_CAP_MIL...Nothing !

Testing driver CV_CAP_VFW...Nothing !

Testing driver CV_CAP_FIREWARE...Nothing !

Testing driver CV_CAP_STEREO...Nothing !

Testing driver CV_CAP_QT...Nothing !

Testing driver CV_CAP_UNICAP...Nothing !

Testing driver CV_CAP_DSHOW... CV_CAP_DSHOW+0 opens: OK grabs: OK

CV_CAP_DSHOW+1 opens: OK grabs: FAIL

Testing driver CV_CAP_MSMF...Nothing !

Testing driver CV_CAP_PVAPI...Nothing !

Testing driver CV_CAP_OPENNI...Nothing !

Testing driver CV_CAP_OPENNI_ASUS...Nothing !

Following is the code :

// Camera_21413.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <vector>

#include "opencv.hpp"
#include "core/core.hpp"
#include "highgui/highgui.hpp"

using namespace cv;
using namespace std;

bool EnumerateCameras(vector<int> &camIdx)
{
    camIdx.clear();
    struct CapDriver{
        int enumValue; string enumName; string comment;
    };
    // list of all CAP drivers (see highgui_c.h)
    vector<CapDriver> drivers;
    CapDriver temp = {CV_CAP_MIL, "CV_CAP_MIL", "MIL proprietary drivers"};
    drivers.push_back( temp );

    temp.enumValue  = CV_CAP_VFW;
    temp.enumName = "CV_CAP_VFW";
    temp.comment  = "platform native";
    drivers.push_back( temp );

    temp.enumValue  = CV_CAP_FIREWARE;
    temp.enumName = "CV_CAP_FIREWARE";
    temp.comment  = "IEEE 1394 drivers";
    drivers.push_back( temp );
    //drivers.push_back({ CV_CAP_FIREWARE, "CV_CAP_FIREWARE", "IEEE 1394 drivers" });

    temp.enumValue  = CV_CAP_STEREO;
    temp.enumName = "CV_CAP_STEREO";
    temp.comment  = "TYZX proprietary drivers";
    drivers.push_back( temp );
    //drivers.push_back({ CV_CAP_STEREO, "CV_CAP_STEREO", "TYZX proprietary drivers" });

    temp.enumValue  = CV_CAP_QT;
    temp.enumName = "CV_CAP_QT";
    temp.comment  = "QuickTime";
    drivers.push_back( temp );
   // drivers.push_back({ CV_CAP_QT, "CV_CAP_QT", "QuickTime" });

    temp.enumValue  = CV_CAP_UNICAP;
    temp.enumName = "CV_CAP_UNICAP";
    temp.comment  = "Unicap drivers";
    drivers.push_back( temp );
    //drivers.push_back({ CV_CAP_UNICAP, "CV_CAP_UNICAP", "Unicap drivers" });

    temp.enumValue  = CV_CAP_DSHOW;
    temp.enumName = "CV_CAP_DSHOW";
    temp.comment  = "DirectShow (via videoInput)";
    drivers.push_back( temp );
    //drivers.push_back({ CV_CAP_DSHOW, "CV_CAP_DSHOW", "DirectShow (via videoInput)" });

    temp.enumValue  = CV_CAP_MSMF;
    temp.enumName = "CV_CAP_MSMF";
    temp.comment  = "Microsoft Media Foundation (via videoInput)";
    drivers.push_back( temp );
    //drivers.push_back({ CV_CAP_MSMF, "CV_CAP_MSMF", "Microsoft Media Foundation (via videoInput)" });

    temp.enumValue  = CV_CAP_PVAPI;
    temp.enumName = "CV_CAP_PVAPI";
    temp.comment  = "PvAPI, Prosilica GigE SDK";
    drivers.push_back( temp );
    //drivers.push_back({ CV_CAP_PVAPI, "CV_CAP_PVAPI", "PvAPI, Prosilica GigE SDK" });

    temp.enumValue  = CV_CAP_OPENNI;
    temp.enumName = "CV_CAP_OPENNI";
    temp.comment  = "OpenNI (for Kinect)";
    drivers.push_back( temp );
    //drivers.push_back({ CV_CAP_OPENNI, "CV_CAP_OPENNI", "OpenNI (for Kinect)" });

    temp.enumValue  = CV_CAP_OPENNI_ASUS;
    temp.enumName = "CV_CAP_OPENNI_ASUS";
    temp.comment  = "OpenNI (for Asus Xtion)";
    drivers.push_back( temp );

    //drivers.push_back({ CV_CAP_android, "CV_CAP_ANDROID", "Android" });

    temp.enumValue  = CV_CAP_ANDROID_BACK;
    temp.enumName = "CV_CAP_ANDROID_BACK";
    temp.comment  = "Android back camera";
    drivers.push_back( temp );
    //drivers.push_back({ CV_CAP_ANDROID_BACK, "CV_CAP_ANDROID_BACK", "Android back camera" });

        temp.enumValue  = CV_CAP_ANDROID_FRONT;
    temp.enumName = "CV_CAP_ANDROID_FRONT";
    temp.comment  = "Android front camera";
    drivers.push_back( temp );
    //drivers.push_back({ CV_CAP_ANDROID_FRONT, "CV_CAP_ANDROID_FRONT", "Android front camera" });

    temp.enumValue  = CV_CAP_XIAPI;
    temp.enumName = "CV_CAP_XIAPI";
    temp.comment  = "XIMEA Camera API";
    drivers.push_back( temp );
    //drivers.push_back({ CV_CAP_XIAPI, "CV_CAP_XIAPI", "XIMEA Camera API" });

    temp.enumValue  = CV_CAP_AVFOUNDATION;
    temp.enumName = "CV_CAP_AVFOUNDATION";
    temp.comment  = "AVFoundation framework for iOS";
    drivers.push_back( temp );
    //drivers.push_back({ CV_CAP_AVFOUNDATION, "CV_CAP_AVFOUNDATION", "AVFoundation framework for iOS" });

    temp.enumValue  = CV_CAP_GIGANETIX;
    temp.enumName = "CV_CAP_GIGANETIX";
    temp.comment  = "Smartek Giganetix GigEVisionSDK";
    drivers.push_back( temp );
    //drivers.push_back({ CV_CAP_GIGANETIX, "CV_CAP_GIGANETIX", "Smartek Giganetix GigEVisionSDK" });

    temp.enumValue  = CV_CAP_INTELPERC;
    temp.enumName = "CV_CAP_INTELPERC";
    temp.comment  = "Intel Perceptual Computing SDK";
    drivers.push_back( temp );
    //drivers.push_back({ CV_CAP_INTELPERC, "CV_CAP_INTELPERC", "Intel Perceptual Computing SDK" });

    std::string winName ...
(more)