Commit 6d0407b6 authored by Piotr Dobrowolski's avatar Piotr Dobrowolski

VideoCapture with digital camera and gPhoto2 library

parent 298c98ea
......@@ -205,6 +205,7 @@ OCV_OPTION(WITH_DIRECTX "Include DirectX support" ON
OCV_OPTION(WITH_INTELPERC "Include Intel Perceptual Computing support" OFF IF (WIN32 AND NOT WINRT) )
OCV_OPTION(WITH_IPP_A "Include Intel IPP_A support" OFF IF (MSVC OR X86 OR X86_64) )
OCV_OPTION(WITH_GDAL "Include GDAL Support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_GPHOTO2 "Include gPhoto2 library support" ON IF (UNIX AND NOT ANDROID) )
# OpenCV build components
# ===================================================
......@@ -1032,6 +1033,10 @@ if(DEFINED WITH_INTELPERC)
status(" Intel PerC:" HAVE_INTELPERC THEN "YES" ELSE NO)
endif(DEFINED WITH_INTELPERC)
if(DEFINED WITH_GPHOTO2)
status(" gPhoto2:" HAVE_GPHOTO2 THEN "YES" ELSE NO)
endif(DEFINED WITH_GPHOTO2)
# ========================== Other third-party libraries ==========================
status("")
......
......@@ -311,3 +311,9 @@ endif()
if(WITH_INTELPERC)
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindIntelPerCSDK.cmake")
endif(WITH_INTELPERC)
# --- gPhoto2 ---
ocv_clear_vars(HAVE_GPHOTO2)
if(WITH_GPHOTO2)
CHECK_MODULE(libgphoto2 HAVE_GPHOTO2)
endif(WITH_GPHOTO2)
......@@ -178,3 +178,6 @@
/* Define if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
#cmakedefine WORDS_BIGENDIAN
/* gPhoto2 library */
#cmakedefine HAVE_GPHOTO2
......@@ -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
......
......@@ -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
......
......@@ -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 );
......
......@@ -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
};
......@@ -537,6 +540,7 @@ static Ptr<IVideoCapture> IVideoCapture_create(int index)
#if defined(HAVE_DSHOW) || \
defined(HAVE_INTELPERC) || \
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)
{
int domains[] =
{
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>();
}
......
This diff is collapsed.
......@@ -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_ */
......@@ -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
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment