VideoCapture with digital camera and gPhoto2 library

This commit is contained in:
Piotr Dobrowolski
2015-05-21 00:41:39 +02:00
parent 298c98ea32
commit 6d0407b65e
11 changed files with 1788 additions and 10 deletions

View File

@@ -186,6 +186,10 @@ if(HAVE_INTELPERC)
list(APPEND VIDEOIO_LIBRARIES ${INTELPERC_LIBRARIES})
endif(HAVE_INTELPERC)
if(HAVE_GPHOTO2)
list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_gphoto2.cpp)
endif(HAVE_GPHOTO2)
if(IOS)
add_definitions(-DHAVE_IOS=1)
list(APPEND videoio_srcs

View File

@@ -89,7 +89,8 @@ enum { CAP_ANY = 0, // autodetect
CAP_WINRT = 1410, // Microsoft Windows Runtime using Media Foundation
CAP_INTELPERC = 1500, // Intel Perceptual Computing SDK
CAP_OPENNI2 = 1600, // OpenNI2 (for Kinect)
CAP_OPENNI2_ASUS = 1610 // OpenNI2 (for Asus Xtion and Occipital Structure sensors)
CAP_OPENNI2_ASUS = 1610, // OpenNI2 (for Asus Xtion and Occipital Structure sensors)
CAP_GPHOTO2 = 1700 // gPhoto2 connection
};
// generic properties (based on DC1394 properties)
@@ -382,6 +383,23 @@ enum { VIDEOWRITER_PROP_QUALITY = 1, // Quality (0..100%) of the videostream
VIDEOWRITER_PROP_FRAMEBYTES = 2, // (Read-only): Size of just encoded video frame
};
// gPhoto2 properties, if propertyId is less than 0 then work on widget with that __additive inversed__ camera setting ID
// Get IDs by using CAP_PROP_GPHOTO2_WIDGET_ENUMERATE.
// @see CvCaptureCAM_GPHOTO2 for more info
enum { CAP_PROP_GPHOTO2_PREVIEW = 17001, // Capture only preview from liveview mode.
CAP_PROP_GPHOTO2_WIDGET_ENUMERATE = 17002, // Readonly, returns (const char *).
CAP_PROP_GPHOTO2_RELOAD_CONFIG = 17003, // Trigger, only by set. Reload camera settings.
CAP_PROP_GPHOTO2_RELOAD_ON_CHANGE = 17004, // Reload all settings on set.
CAP_PROP_GPHOTO2_COLLECT_MSGS = 17005, // Collect messages with details.
CAP_PROP_GPHOTO2_FLUSH_MSGS = 17006, // Readonly, returns (const char *).
CAP_PROP_SPEED = 17007, // Exposure speed. Can be readonly, depends on camera program.
CAP_PROP_APERTURE = 17008, // Aperture. Can be readonly, depends on camera program.
CAP_PROP_EXPOSUREPROGRAM = 17009, // Camera exposure program.
CAP_PROP_VIEWFINDER = 17010 // Enter liveview mode.
};
//enum {
class IVideoCapture;
/** @brief Class for video capturing from video files, image sequences or cameras. The class provides C++ API

View File

@@ -110,7 +110,9 @@ enum
CV_CAP_INTELPERC = 1500, // Intel Perceptual Computing
CV_CAP_OPENNI2 = 1600 // OpenNI2 (for Kinect)
CV_CAP_OPENNI2 = 1600, // OpenNI2 (for Kinect)
CV_CAP_GPHOTO2 = 1700
};
/* start capturing frames from camera: index = camera_index + domain_offset (CV_CAP_*) */
@@ -391,6 +393,23 @@ enum
CV_CAP_INTELPERC_IMAGE = 3
};
// gPhoto2 properties, if propertyId is less than 0 then work on widget with that __additive inversed__ camera setting ID
// Get IDs by using CAP_PROP_GPHOTO2_WIDGET_ENUMERATE.
// @see CvCaptureCAM_GPHOTO2 for more info
enum
{
CV_CAP_PROP_GPHOTO2_PREVIEW = 17001, // Capture only preview from liveview mode.
CV_CAP_PROP_GPHOTO2_WIDGET_ENUMERATE = 17002, // Readonly, returns (const char *).
CV_CAP_PROP_GPHOTO2_RELOAD_CONFIG = 17003, // Trigger, only by set. Reload camera settings.
CV_CAP_PROP_GPHOTO2_RELOAD_ON_CHANGE = 17004, // Reload all settings on set.
CV_CAP_PROP_GPHOTO2_COLLECT_MSGS = 17005, // Collect messages with details.
CV_CAP_PROP_GPHOTO2_FLUSH_MSGS = 17006, // Readonly, returns (const char *).
CV_CAP_PROP_SPEED = 17007, // Exposure speed. Can be readonly, depends on camera program.
CV_CAP_PROP_APERTURE = 17008, // Aperture. Can be readonly, depends on camera program.
CV_CAP_PROP_EXPOSUREPROGRAM = 17009, // Camera exposure program.
CV_CAP_PROP_VIEWFINDER = 17010 // Enter liveview mode.
};
/* retrieve or set capture properties */
CVAPI(double) cvGetCaptureProperty( CvCapture* capture, int property_id );
CVAPI(int) cvSetCaptureProperty( CvCapture* capture, int property_id, double value );

View File

@@ -518,6 +518,9 @@ static Ptr<IVideoCapture> IVideoCapture_create(int index)
#endif
#ifdef WINRT_VIDEO
CAP_WINRT,
#endif
#ifdef HAVE_GPHOTO2
CV_CAP_GPHOTO2,
#endif
-1, -1
};
@@ -536,7 +539,8 @@ static Ptr<IVideoCapture> IVideoCapture_create(int index)
{
#if defined(HAVE_DSHOW) || \
defined(HAVE_INTELPERC) || \
defined(WINRT_VIDEO) || \
defined(WINRT_VIDEO) || \
defined(HAVE_GPHOTO2) || \
(0)
Ptr<IVideoCapture> capture;
@@ -558,6 +562,11 @@ static Ptr<IVideoCapture> IVideoCapture_create(int index)
if (capture)
return capture;
break; // CAP_WINRT
#endif
#ifdef HAVE_GPHOTO2
case CV_CAP_GPHOTO2:
capture = createGPhoto2Capture(index);
break;
#endif
}
if (capture && capture->isOpened())
@@ -572,14 +581,37 @@ static Ptr<IVideoCapture> IVideoCapture_create(int index)
static Ptr<IVideoCapture> IVideoCapture_create(const String& filename)
{
Ptr<IVideoCapture> capture;
capture = createMotionJpegCapture(filename);
if (capture && capture->isOpened())
int domains[] =
{
return capture;
}
CV_CAP_ANY,
#ifdef HAVE_GPHOTO2
CV_CAP_GPHOTO2,
#endif
-1, -1
};
// try every possibly installed camera API
for (int i = 0; domains[i] >= 0; i++)
{
Ptr<IVideoCapture> capture;
switch (domains[i])
{
case CV_CAP_ANY:
capture = createMotionJpegCapture(filename);
break;
#ifdef HAVE_GPHOTO2
case CV_CAP_GPHOTO2:
capture = createGPhoto2Capture(filename);
break;
#endif
}
if (capture && capture->isOpened())
{
return capture;
}
}
// failed open a camera
return Ptr<IVideoCapture>();
}
@@ -800,4 +832,4 @@ int VideoWriter::fourcc(char c1, char c2, char c3, char c4)
return (c1 & 255) + ((c2 & 255) << 8) + ((c3 & 255) << 16) + ((c4 & 255) << 24);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -186,6 +186,9 @@ namespace cv
Ptr<IVideoCapture> createMotionJpegCapture(const String& filename);
Ptr<IVideoWriter> createMotionJpegWriter( const String& filename, double fps, Size frameSize, bool iscolor );
Ptr<IVideoCapture> createGPhoto2Capture(int index);
Ptr<IVideoCapture> createGPhoto2Capture(const String& deviceName);
};
#endif /* __VIDEOIO_H_ */

View File

@@ -37,6 +37,7 @@
defined(HAVE_AVFOUNDATION) || \
defined(HAVE_GIGE_API) || \
defined(HAVE_INTELPERC) || \
defined(HAVE_GPHOTO2) || \
(0)
//defined(HAVE_ANDROID_NATIVE_CAMERA) || - enable after #1193
# define BUILD_WITH_CAMERA_SUPPORT 1