a Question on Gphoto - OpenCV code

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

a Question on Gphoto - OpenCV code

ehsan kiani

Dear Sir or Madam;

 

First I would like to appreciate providing a helpful open source program for researchers who want to access digital camera on Linux.

 Indeed, I experienced difficulties to use Gphoto2 for a real-time video capture project. Actually, compiling the attached C++ / OpenCV code on Linux machine does not recognize the camera. Would you mind helping me on this matter?

I look forward to hearing from you.

 

Sincerely,

Ehsan Kiani

 



------------------------------------------------------------------------------

_______________________________________________
Gphoto-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gphoto-devel

cameracapture.cpp (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: a Question on Gphoto - OpenCV code

Marcus Meissner
Hi,

The VideoCapture class in OpenCV seems to be for webcams (video4linux)
based ones, not for stillcameras like supported by libgphoto2.

There seems no class for Gphoto cameras there yet.

Ciao, Marcus
On Sat, Dec 12, 2015 at 07:23:18PM +0200, ehsan kiani wrote:

> Dear Sir or Madam;
>
> First I would like to appreciate providing a helpful open source program
> <http://www.gphoto.org/doc/remote/> for researchers who want to access
> digital camera on Linux.
>
>  Indeed, I experienced difficulties to use Gphoto2 for a real-time video
> capture project. Actually, compiling the attached C++ / OpenCV code on
> Linux machine does not recognize the camera. Would you mind helping me on
> this matter?
>
> I look forward to hearing from you.
>
> Sincerely,
>
> Ehsan Kiani

> #include "opencv2/highgui/highgui.hpp"
> #include <iostream>
>
> using namespace cv;
> using namespace std;
>
> int main(int argc, char* argv[])
> {
>     VideoCapture cap(0); // open the video camera no. 0
>
>     if (!cap.isOpened())  // if not success, exit program
>     {
>         cout << "Cannot open the video cam" << endl;
>         return -1;
>     }
>
>    double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
>    double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video
>
>     cout << "Frame size : " << dWidth << " x " << dHeight << endl;
>
>     namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"
>
>     while (1)
>     {
>         Mat frame;
>
>         bool bSuccess = cap.read(frame); // read a new frame from video
>
>          if (!bSuccess) //if not success, break loop
>         {
>              cout << "Cannot read a frame from video stream" << endl;
>              break;
>         }
>
>         imshow("MyVideo", frame); //show the frame in "MyVideo" window
>
>         if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
>        {
>             cout << "esc key is pressed by user" << endl;
>             break;
>        }
>     }
>     return 0;
>
> }
> ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

> ------------------------------------------------------------------------------

> _______________________________________________
> Gphoto-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gphoto-devel

--
Marcus Meissner,SUSE LINUX GmbH; Maxfeldstrasse 5; D-90409 Nuernberg; Zi. 3.1-33,+49-911-740 53-432,,serv=loki,mail=wotan,type=real <[hidden email]>

------------------------------------------------------------------------------
_______________________________________________
Gphoto-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gphoto-devel
Reply | Threaded
Open this post in threaded view
|

Re: a Question on Gphoto - OpenCV code

NDimCube
That's a pity I haven't seen it before - just ran across this post by accident.
Still It's good to answer. Good to know someone was asking.

I added to OpenCV an implementation of VideoCapture
that wraps gPhoto2. It is in OpenCV since version 3.0 (June 2015).

As example I wrote simple autofocus using OpenCV and gPhoto2.
https://github.com/dobrypd/autofocus
It is in OpenCV samples:
https://github.com/Itseez/opencv/blob/master/samples/cpp/autofocus.cpp

To be able to use library gPhoto2 in OpenCV it has to be built with gPhoto2.
Like that
 * on MacOsX (using brew)
$ brew install opencv3 --with-gphoto2
 * or from sources (at some point):
$ cmake (...) -D WITH_GPHOTO2=ON