mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
videoio: refactor AVFoundation code integration
This commit is contained in:
@@ -168,12 +168,13 @@ if(HAVE_GIGE_API)
|
||||
endif(HAVE_GIGE_API)
|
||||
|
||||
if(HAVE_AVFOUNDATION)
|
||||
list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_avfoundation.mm)
|
||||
list(APPEND VIDEOIO_LIBRARIES "-framework AVFoundation" "-framework QuartzCore")
|
||||
endif()
|
||||
if(HAVE_AVFOUNDATION_MAC)
|
||||
list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_avfoundation_mac.mm)
|
||||
list(APPEND VIDEOIO_LIBRARIES "-framework Cocoa" "-framework Accelerate" "-framework AVFoundation" "-framework CoreGraphics" "-framework CoreImage" "-framework CoreMedia" "-framework CoreVideo" "-framework QuartzCore")
|
||||
if(IOS)
|
||||
list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_avfoundation.mm)
|
||||
list(APPEND VIDEOIO_LIBRARIES "-framework AVFoundation" "-framework QuartzCore")
|
||||
else()
|
||||
list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_avfoundation_mac.mm)
|
||||
list(APPEND VIDEOIO_LIBRARIES "-framework Cocoa" "-framework Accelerate" "-framework AVFoundation" "-framework CoreGraphics" "-framework CoreImage" "-framework CoreMedia" "-framework CoreVideo" "-framework QuartzCore")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(HAVE_QUICKTIME)
|
||||
|
||||
@@ -82,35 +82,34 @@ To enable/disable APIs, you have to:
|
||||
2. rebuild OpenCV itself
|
||||
*/
|
||||
enum VideoCaptureAPIs {
|
||||
CAP_ANY = 0, //!< Auto detect
|
||||
CAP_VFW = 200, //!< Video For Windows (platform native)
|
||||
CAP_V4L = 200, //!< V4L/V4L2 capturing support via libv4l
|
||||
CAP_V4L2 = CAP_V4L, //!< Same as CAP_V4L
|
||||
CAP_FIREWIRE = 300, //!< IEEE 1394 drivers
|
||||
CAP_FIREWARE = CAP_FIREWIRE, //!< Same as CAP_FIREWIRE
|
||||
CAP_IEEE1394 = CAP_FIREWIRE, //!< Same as CAP_FIREWIRE
|
||||
CAP_DC1394 = CAP_FIREWIRE, //!< Same as CAP_FIREWIRE
|
||||
CAP_CMU1394 = CAP_FIREWIRE, //!< Same as CAP_FIREWIRE
|
||||
CAP_QT = 500, //!< QuickTime
|
||||
CAP_UNICAP = 600, //!< Unicap drivers
|
||||
CAP_DSHOW = 700, //!< DirectShow (via videoInput)
|
||||
CAP_PVAPI = 800, //!< PvAPI, Prosilica GigE SDK
|
||||
CAP_OPENNI = 900, //!< OpenNI (for Kinect)
|
||||
CAP_OPENNI_ASUS = 910, //!< OpenNI (for Asus Xtion)
|
||||
CAP_ANDROID = 1000, //!< Android - not used
|
||||
CAP_XIAPI = 1100, //!< XIMEA Camera API
|
||||
CAP_AVFOUNDATION = 1200, //!< AVFoundation framework for iOS
|
||||
CAP_AVFOUNDATION_MAC = 1210, //!< AVFoundation framework for macOS
|
||||
CAP_GIGANETIX = 1300, //!< Smartek Giganetix GigEVisionSDK
|
||||
CAP_MSMF = 1400, //!< Microsoft Media Foundation (via videoInput)
|
||||
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_GPHOTO2 = 1700, //!< gPhoto2 connection
|
||||
CAP_GSTREAMER = 1800, //!< GStreamer
|
||||
CAP_FFMPEG = 1900, //!< FFMPEG
|
||||
CAP_IMAGES = 2000 //!< OpenCV Image Sequence (e.g. img_%02d.jpg)
|
||||
CAP_ANY = 0, //!< Auto detect
|
||||
CAP_VFW = 200, //!< Video For Windows (platform native)
|
||||
CAP_V4L = 200, //!< V4L/V4L2 capturing support via libv4l
|
||||
CAP_V4L2 = CAP_V4L, //!< Same as CAP_V4L
|
||||
CAP_FIREWIRE = 300, //!< IEEE 1394 drivers
|
||||
CAP_FIREWARE = CAP_FIREWIRE, //!< Same as CAP_FIREWIRE
|
||||
CAP_IEEE1394 = CAP_FIREWIRE, //!< Same as CAP_FIREWIRE
|
||||
CAP_DC1394 = CAP_FIREWIRE, //!< Same as CAP_FIREWIRE
|
||||
CAP_CMU1394 = CAP_FIREWIRE, //!< Same as CAP_FIREWIRE
|
||||
CAP_QT = 500, //!< QuickTime
|
||||
CAP_UNICAP = 600, //!< Unicap drivers
|
||||
CAP_DSHOW = 700, //!< DirectShow (via videoInput)
|
||||
CAP_PVAPI = 800, //!< PvAPI, Prosilica GigE SDK
|
||||
CAP_OPENNI = 900, //!< OpenNI (for Kinect)
|
||||
CAP_OPENNI_ASUS = 910, //!< OpenNI (for Asus Xtion)
|
||||
CAP_ANDROID = 1000, //!< Android - not used
|
||||
CAP_XIAPI = 1100, //!< XIMEA Camera API
|
||||
CAP_AVFOUNDATION = 1200, //!< AVFoundation framework for iOS (OS X Lion will have the same API)
|
||||
CAP_GIGANETIX = 1300, //!< Smartek Giganetix GigEVisionSDK
|
||||
CAP_MSMF = 1400, //!< Microsoft Media Foundation (via videoInput)
|
||||
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_GPHOTO2 = 1700, //!< gPhoto2 connection
|
||||
CAP_GSTREAMER = 1800, //!< GStreamer
|
||||
CAP_FFMPEG = 1900, //!< FFMPEG
|
||||
CAP_IMAGES = 2000 //!< OpenCV Image Sequence (e.g. img_%02d.jpg)
|
||||
};
|
||||
|
||||
//! generic properties (based on DC1394 properties)
|
||||
|
||||
@@ -108,7 +108,6 @@ enum
|
||||
CV_CAP_XIAPI =1100, // XIMEA Camera API
|
||||
|
||||
CV_CAP_AVFOUNDATION = 1200, // AVFoundation framework for iOS (OS X Lion will have the same API)
|
||||
CV_CAP_AVFOUNDATION_MAC = 1210, // AVFoundation framework for Mac
|
||||
|
||||
CV_CAP_GIGANETIX = 1300, // Smartek Giganetix GigEVisionSDK
|
||||
|
||||
|
||||
@@ -266,12 +266,6 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
|
||||
if (pref) break;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_AVFOUNDATION_MAC
|
||||
case CV_CAP_AVFOUNDATION_MAC:
|
||||
TRY_OPEN(capture, cvCreateCameraCapture_AVFoundation_Mac(index))
|
||||
if (pref) break;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GIGE_API
|
||||
case CV_CAP_GIGANETIX:
|
||||
TRY_OPEN(capture, cvCreateCameraCapture_Giganetix(index))
|
||||
@@ -340,12 +334,6 @@ CV_IMPL CvCapture * cvCreateFileCaptureWithPreference (const char * filename, in
|
||||
if (apiPreference) break;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_AVFOUNDATION_MAC
|
||||
case CV_CAP_AVFOUNDATION_MAC:
|
||||
TRY_OPEN(result, cvCreateFileCapture_AVFoundation_Mac(filename))
|
||||
if (apiPreference) break;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENNI
|
||||
case CV_CAP_OPENNI:
|
||||
TRY_OPEN(result, cvCreateFileCapture_OpenNI (filename))
|
||||
@@ -403,10 +391,6 @@ CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc,
|
||||
TRY_OPEN(result, cvCreateVideoWriter_AVFoundation(filename, fourcc, fps, frameSize, is_color))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_AVFOUNDATION_MAC
|
||||
TRY_OPEN(result, cvCreateVideoWriter_AVFoundation_Mac(filename, fourcc, fps, frameSize, is_color))
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_QUICKTIME) || defined(HAVE_QTKIT)
|
||||
TRY_OPEN(result, cvCreateVideoWriter_QT(filename, fourcc, fps, frameSize, is_color))
|
||||
#endif
|
||||
|
||||
@@ -171,18 +171,18 @@ private:
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* CvVideoWriter_AVFoundation_Mac Declaration.
|
||||
* CvVideoWriter_AVFoundation Declaration.
|
||||
*
|
||||
* CvVideoWriter_AVFoundation_Mac is the instantiation of a video output class.
|
||||
* CvVideoWriter_AVFoundation is the instantiation of a video output class.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
class CvVideoWriter_AVFoundation_Mac : public CvVideoWriter {
|
||||
class CvVideoWriter_AVFoundation : public CvVideoWriter {
|
||||
public:
|
||||
CvVideoWriter_AVFoundation_Mac(const char* filename, int fourcc,
|
||||
CvVideoWriter_AVFoundation(const char* filename, int fourcc,
|
||||
double fps, CvSize frame_size,
|
||||
int is_color=1);
|
||||
~CvVideoWriter_AVFoundation_Mac();
|
||||
~CvVideoWriter_AVFoundation();
|
||||
bool writeFrame(const IplImage* image);
|
||||
private:
|
||||
IplImage* argbimage;
|
||||
@@ -203,7 +203,7 @@ class CvVideoWriter_AVFoundation_Mac : public CvVideoWriter {
|
||||
/****************** Implementation of interface functions ********************/
|
||||
|
||||
|
||||
CvCapture* cvCreateFileCapture_AVFoundation_Mac(const char* filename) {
|
||||
CvCapture* cvCreateFileCapture_AVFoundation(const char* filename) {
|
||||
CvCaptureFile *retval = new CvCaptureFile(filename);
|
||||
|
||||
if(retval->didStart())
|
||||
@@ -212,17 +212,17 @@ CvCapture* cvCreateFileCapture_AVFoundation_Mac(const char* filename) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CvCapture* cvCreateCameraCapture_AVFoundation_Mac(int index ) {
|
||||
CvCapture* cvCreateCameraCapture_AVFoundation(int index ) {
|
||||
CvCapture* retval = new CvCaptureCAM(index);
|
||||
if (!((CvCaptureCAM *)retval)->didStart())
|
||||
cvReleaseCapture(&retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
CvVideoWriter* cvCreateVideoWriter_AVFoundation_Mac(const char* filename, int fourcc,
|
||||
CvVideoWriter* cvCreateVideoWriter_AVFoundation(const char* filename, int fourcc,
|
||||
double fps, CvSize frame_size,
|
||||
int is_color) {
|
||||
return new CvVideoWriter_AVFoundation_Mac(filename, fourcc, fps, frame_size,is_color);
|
||||
return new CvVideoWriter_AVFoundation(filename, fourcc, fps, frame_size,is_color);
|
||||
}
|
||||
|
||||
/********************** Implementation of Classes ****************************/
|
||||
@@ -1087,14 +1087,14 @@ bool CvCaptureFile::setProperty(int property_id, double value) {
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* CvVideoWriter_AVFoundation_Mac Implementation.
|
||||
* CvVideoWriter_AVFoundation Implementation.
|
||||
*
|
||||
* CvVideoWriter_AVFoundation_Mac is the instantiation of a video output class.
|
||||
* CvVideoWriter_AVFoundation is the instantiation of a video output class.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
CvVideoWriter_AVFoundation_Mac::CvVideoWriter_AVFoundation_Mac(const char* filename, int fourcc,
|
||||
CvVideoWriter_AVFoundation::CvVideoWriter_AVFoundation(const char* filename, int fourcc,
|
||||
double fps, CvSize frame_size,
|
||||
int is_color) {
|
||||
|
||||
@@ -1222,7 +1222,7 @@ CvVideoWriter_AVFoundation_Mac::CvVideoWriter_AVFoundation_Mac(const char* filen
|
||||
}
|
||||
|
||||
|
||||
CvVideoWriter_AVFoundation_Mac::~CvVideoWriter_AVFoundation_Mac() {
|
||||
CvVideoWriter_AVFoundation::~CvVideoWriter_AVFoundation() {
|
||||
NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
[mMovieWriterInput markAsFinished];
|
||||
@@ -1243,7 +1243,7 @@ static void releaseCallback( void *releaseRefCon, const void * ) {
|
||||
CFRelease((CFDataRef)releaseRefCon);
|
||||
}
|
||||
|
||||
bool CvVideoWriter_AVFoundation_Mac::writeFrame(const IplImage* iplimage) {
|
||||
bool CvVideoWriter_AVFoundation::writeFrame(const IplImage* iplimage) {
|
||||
NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
// writer status check
|
||||
|
||||
@@ -127,7 +127,6 @@ CvCapture* cvCreateFileCapture_OpenNI( const char* filename );
|
||||
CvCapture* cvCreateCameraCapture_Android( int index );
|
||||
CvCapture* cvCreateCameraCapture_XIMEA( int index );
|
||||
CvCapture* cvCreateCameraCapture_AVFoundation(int index);
|
||||
CvCapture* cvCreateCameraCapture_AVFoundation_Mac(int index);
|
||||
|
||||
CvCapture* cvCreateFileCapture_Images(const char* filename);
|
||||
CvVideoWriter* cvCreateVideoWriter_Images(const char* filename);
|
||||
@@ -156,9 +155,6 @@ CvVideoWriter* cvCreateVideoWriter_QT ( const char* filename, int fourcc,
|
||||
CvCapture* cvCreateFileCapture_AVFoundation (const char * filename);
|
||||
CvVideoWriter* cvCreateVideoWriter_AVFoundation( const char* filename, int fourcc,
|
||||
double fps, CvSize frameSize, int is_color );
|
||||
CvCapture* cvCreateFileCapture_AVFoundation_Mac(const char * filename);
|
||||
CvVideoWriter* cvCreateVideoWriter_AVFoundation_Mac( const char* filename, int fourcc,
|
||||
double fps, CvSize frameSize, int is_color );
|
||||
|
||||
|
||||
CvCapture * cvCreateCameraCapture_Unicap (const int index);
|
||||
|
||||
Reference in New Issue
Block a user