Skip to content

Commit 3a3bc18

Browse files
author
Artem Myagkov
committed
modified capturing building ligic for iOS
1 parent 8c67823 commit 3a3bc18

File tree

6 files changed

+42
-20
lines changed

6 files changed

+42
-20
lines changed

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ set(WITH_JPEG ON CACHE BOOL "Include JPEG support")
414414
set(WITH_JASPER ON CACHE BOOL "Include JPEG2K support")
415415
set(WITH_TIFF ON CACHE BOOL "Include TIFF support")
416416
set(WITH_OPENEXR ON CACHE BOOL "Include ILM support via OpenEXR")
417-
endif()
417+
418418

419419
if(UNIX)
420420
set(WITH_FFMPEG ON CACHE BOOL "Include FFMPEG support")
@@ -429,11 +429,17 @@ if(UNIX)
429429
set(WITH_1394 ON CACHE BOOL "Include IEEE1394 support")
430430
endif()
431431

432+
endif()
433+
432434
if(APPLE)
433435
set(WITH_CARBON OFF CACHE BOOL "Use Carbon for UI instead of Cocoa")
434436
set(WITH_QUICKTIME OFF CACHE BOOL "Use QuickTime for Video I/O insted of QTKit")
435437
endif()
436438

439+
if(IOS)
440+
set(WITH_AVFOUNDATION ON CACHE BOOL "Use AVFoundation for Video I/O")
441+
endif()
442+
437443
set(WITH_TBB OFF CACHE BOOL "Include Intel TBB support")
438444
set(WITH_IPP OFF CACHE BOOL "Include Intel IPP support")
439445
set(WITH_EIGEN ON CACHE BOOL "Include Eigen2/Eigen3 support")

cvconfig.h.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@
100100
/* QuickTime video libraries */
101101
#cmakedefine HAVE_QUICKTIME
102102

103+
/* AVFoundation video libraries */
104+
#cmakedefine HAVE_AVFOUNDATION
105+
103106
/* TIFF codec */
104107
#cmakedefine HAVE_TIFF
105108

ios/cmake/Toolchains/Toolchain-iPhoneSimulator_Xcode.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
message (STATUS "Setting up iPhoneOS toolchain")
1+
message (STATUS "Setting up iPhoneSimulator toolchain")
22
set (IPHONESIMULATOR TRUE)
33

44
# Standard settings
@@ -21,4 +21,4 @@ SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
2121
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
2222
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
2323

24-
message (STATUS "iPhoneOS toolchain loaded")
24+
message (STATUS "iPhoneSimulator toolchain loaded")

modules/highgui/CMakeLists.txt

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ if(WIN32)
125125
endif()
126126
endif()
127127

128-
if(UNIX)
129-
if(NOT IOS)
130-
128+
if(UNIX)
131129
if(NOT HAVE_QT)
132130
if(HAVE_GTK)
133131
set(highgui_srcs ${highgui_srcs} src/window_gtk.cpp)
@@ -174,8 +172,6 @@ if(UNIX)
174172
endif()
175173
endif()
176174

177-
endif(NOT IOS)
178-
179175
foreach(P ${HIGHGUI_INCLUDE_DIRS})
180176
include_directories(${P})
181177
endforeach()
@@ -192,8 +188,11 @@ if(WITH_OPENNI AND HAVE_OPENNI)
192188
endif()
193189

194190
#YV
195-
if(APPLE AND NOT IOS)
196-
add_definitions(-DHAVE_QUICKTIME=1)
191+
if(APPLE)
192+
if (NOT IOS)
193+
add_definitions(-DHAVE_QUICKTIME=1)
194+
endif()
195+
197196
if(NOT OPENCV_BUILD_3RDPARTY_LIBS)
198197
add_definitions(-DHAVE_IMAGEIO=1)
199198
endif()
@@ -211,15 +210,19 @@ if(APPLE AND NOT IOS)
211210
if(WITH_QUICKTIME)
212211
set(highgui_srcs ${highgui_srcs} src/cap_qt.cpp)
213212
else()
214-
set(highgui_srcs ${highgui_srcs} src/cap_qtkit.mm)
213+
if (WITH_AVFOUNDATION)
214+
add_definitions(-DHAVE_AVFOUNDATION=1)
215+
set(highgui_srcs ${highgui_srcs} src/cap_avfoundation.mm)
216+
else()
217+
set(highgui_srcs ${highgui_srcs} src/cap_qtkit.mm)
218+
endif()
215219
endif()
220+
221+
222+
223+
endif(APPLE)
216224

217-
endif(APPLE AND NOT IOS)
218225

219-
if (IOS)
220-
add_definitions(-DHAVE_IMAGEIO=1)
221-
set(highgui_srcs ${highgui_srcs} src/cap_avfoundation.mm)
222-
endif()
223226

224227
if(WITH_ANDROID_CAMERA)
225228
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../androidcamera/include")

modules/highgui/src/cap.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
157157
defined(HAVE_DC1394_2) || defined(HAVE_DC1394) || defined(HAVE_CMU1394) || \
158158
defined(HAVE_GSTREAMER) || defined(HAVE_MIL) || defined(HAVE_QUICKTIME) || \
159159
defined(HAVE_UNICAP) || defined(HAVE_PVAPI) || defined(HAVE_OPENNI) || defined(HAVE_ANDROID_NATIVE_CAMERA) || \
160-
defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR)
160+
defined(HAVE_AVFOUNDATION)
161161
// local variable to memorize the captured device
162162
CvCapture *capture;
163163
#endif
@@ -281,7 +281,7 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
281281
break;
282282
#endif
283283

284-
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
284+
#ifdef HAVE_AVFOUNDATION
285285
case CV_CAP_AVFOUNDATION:
286286
capture = cvCreateCameraCapture_AVFoundation (index);
287287
if (capture)
@@ -321,7 +321,7 @@ CV_IMPL CvCapture * cvCreateFileCapture (const char * filename)
321321
result = cvCreateFileCapture_QT (filename);
322322
#endif
323323

324-
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
324+
#ifdef HAVE_AVFOUNDATION
325325
if (! result)
326326
result = cvCreateFileCapture_AVFoundation (filename);
327327
#endif
@@ -354,7 +354,7 @@ CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc,
354354
result = cvCreateVideoWriter_XINE(filename, fourcc, fps, frameSize, is_color);
355355
#endif
356356
*/
357-
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
357+
#ifdef HAVE_AVFOUNDATION
358358
if (! result)
359359
result = cvCreateVideoWriter_AVFoundation(filename, fourcc, fps, frameSize, is_color);
360360
#endif

modules/highgui/src/precomp.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ CvCapture* cvCreateCameraCapture_DShow( int index );
134134
CvCapture* cvCreateCameraCapture_OpenNI( int index );
135135
CvCapture* cvCreateCameraCapture_Android( int index );
136136
CvCapture* cvCreateCameraCapture_XIMEA( int index );
137+
CvCapture* cvCreateCameraCapture_AVFoundation(int index);
138+
137139

138140
CVAPI(int) cvHaveImageReader(const char* filename);
139141
CVAPI(int) cvHaveImageWriter(const char* filename);
@@ -143,6 +145,9 @@ CvVideoWriter* cvCreateVideoWriter_Images(const char* filename);
143145

144146
CvCapture* cvCreateFileCapture_XINE (const char* filename);
145147

148+
149+
150+
146151
#define CV_CAP_GSTREAMER_1394 0
147152
#define CV_CAP_GSTREAMER_V4L 1
148153
#define CV_CAP_GSTREAMER_V4L2 2
@@ -161,6 +166,11 @@ CvCapture * cvCreateCameraCapture_QT (const int index);
161166
CvVideoWriter* cvCreateVideoWriter_QT ( const char* filename, int fourcc,
162167
double fps, CvSize frameSize, int is_color );
163168

169+
CvCapture* cvCreateFileCapture_AVFoundation (const char * filename);
170+
CvVideoWriter* cvCreateVideoWriter_AVFoundation( const char* filename, int fourcc,
171+
double fps, CvSize frameSize, int is_color );
172+
173+
164174
CvCapture * cvCreateCameraCapture_Unicap (const int index);
165175
CvCapture * cvCreateCameraCapture_PvAPI (const int index);
166176
CvVideoWriter* cvCreateVideoWriter_GStreamer( const char* filename, int fourcc,

0 commit comments

Comments
 (0)