diff --git a/3rdparty/zlib/CMakeLists.txt b/3rdparty/zlib/CMakeLists.txt index 410f2420bf9825d4af796c65f4a038ffc68229d7..853571ef4cfe9c211a288291614c6c414b982ad0 100644 --- a/3rdparty/zlib/CMakeLists.txt +++ b/3rdparty/zlib/CMakeLists.txt @@ -82,7 +82,7 @@ if(UNIX) endif() endif() -ocv_warnings_disable(CMAKE_C_FLAGS -Wattributes -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations) +ocv_warnings_disable(CMAKE_C_FLAGS -Wshorten-64-to-32 -Wattributes -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations) set_target_properties(${ZLIB_LIBRARY} PROPERTIES OUTPUT_NAME ${ZLIB_LIBRARY} diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake index ba74ebe4abf31557f20d18ee010bd3057f822fb0..909e2a471cef28739189960cc2a715343af37305 100644 --- a/cmake/OpenCVCompilerOptions.cmake +++ b/cmake/OpenCVCompilerOptions.cmake @@ -106,6 +106,10 @@ if(CMAKE_COMPILER_IS_GNUCXX) add_extra_compiler_option(-march=i686) endif() + if(APPLE) + add_extra_compiler_option(-Wno-semicolon-before-method-body) + endif() + # Other optimizations if(ENABLE_OMIT_FRAME_POINTER) add_extra_compiler_option(-fomit-frame-pointer) diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake index 96321f9294c8f9e36d3e6a3fad94675bb99de09e..b32465ead2c744e98ad3bdaf9a93eded5c4667ab 100644 --- a/cmake/OpenCVUtils.cmake +++ b/cmake/OpenCVUtils.cmake @@ -242,6 +242,24 @@ macro(ocv_warnings_disable) endif(NOT ENABLE_NOISY_WARNINGS) endmacro() +macro(add_apple_compiler_options the_module) + ocv_check_flag_support(OBJCXX "-fobjc-exceptions" HAVE_OBJC_EXCEPTIONS) + if(HAVE_OBJC_EXCEPTIONS) + foreach(source ${OPENCV_MODULE_${the_module}_SOURCES}) + if("${source}" MATCHES "\\.mm$") + get_source_file_property(flags "${source}" COMPILE_FLAGS) + if(flags) + set(flags "${_flags} -fobjc-exceptions") + else() + set(flags "-fobjc-exceptions") + endif() + + set_source_files_properties("${source}" PROPERTIES COMPILE_FLAGS "${flags}") + endif() + endforeach() + endif() +endmacro() + # Provides an option that the user can optionally select. # Can accept condition to control when option is available for user. # Usage: diff --git a/modules/core/src/parallel.cpp b/modules/core/src/parallel.cpp index 6ebc02df2cba93da4f12e2a478bc8559849ba7d4..5a51230cef65c3f9cb956189616d32287b332837 100644 --- a/modules/core/src/parallel.cpp +++ b/modules/core/src/parallel.cpp @@ -177,7 +177,7 @@ namespace static void block_function(void* context, size_t index) { ProxyLoopBody* ptr_body = static_cast(context); - (*ptr_body)(cv::Range(index, index + 1)); + (*ptr_body)(cv::Range((int)index, (int)index + 1)); } #elif defined HAVE_CONCURRENCY class ProxyLoopBody : public ParallelLoopBodyWrapper diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp index 8ee97273e85677206253fd48a9738e91c1a7d737..fb5648d06f8ffbcbf4101a0b3b029d5f80ba92fe 100644 --- a/modules/core/src/persistence.cpp +++ b/modules/core/src/persistence.cpp @@ -1177,7 +1177,7 @@ force_int: int val, is_hex = d == 'x'; c = ptr[3]; ptr[3] = '\0'; - val = strtol( ptr + is_hex, &endptr, is_hex ? 8 : 16 ); + val = (int)strtol( ptr + is_hex, &endptr, is_hex ? 8 : 16 ); ptr[3] = c; if( endptr == ptr + is_hex ) buf[len++] = 'x'; @@ -2787,7 +2787,7 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co // find the last occurence of for(;;) { - int line_offset = ftell( fs->file ); + int line_offset = (int)ftell( fs->file ); char* ptr0 = icvGets( fs, xml_buf, xml_buf_size ), *ptr; if( !ptr0 ) break; diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt index de8c27ba33ac5a2e15edc0ee9a9fef9383429ace..174a6200200503503119a8af13b8d0766f88b445 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -98,21 +98,7 @@ ocv_create_module(${HIGHGUI_LIBRARIES}) macro(ocv_highgui_configure_target) if(APPLE) - ocv_check_flag_support(OBJCXX "-fobjc-exceptions" HAVE_OBJC_EXCEPTIONS) - if(HAVE_OBJC_EXCEPTIONS) - foreach(source ${OPENCV_MODULE_${the_module}_SOURCES}) - if("${source}" MATCHES "\\.mm$") - get_source_file_property(flags "${source}" COMPILE_FLAGS) - if(flags) - set(flags "${_flags} -fobjc-exceptions") - else() - set(flags "-fobjc-exceptions") - endif() - - set_source_files_properties("${source}" PROPERTIES COMPILE_FLAGS "${flags}") - endif() - endforeach() - endif() + add_apple_compiler_options(the_module) endif() if(BUILD_SHARED_LIBS) diff --git a/modules/imgcodecs/CMakeLists.txt b/modules/imgcodecs/CMakeLists.txt index 67054053cdecddfd92b1d75c188f0ac982e24303..3d0110ef485a8f75dccc10a03fe97ad3581b30c2 100644 --- a/modules/imgcodecs/CMakeLists.txt +++ b/modules/imgcodecs/CMakeLists.txt @@ -106,21 +106,7 @@ ocv_create_module(${GRFMT_LIBS} ${IMGCODECS_LIBRARIES}) macro(ocv_imgcodecs_configure_target) if(APPLE) - ocv_check_flag_support(OBJCXX "-fobjc-exceptions" HAVE_OBJC_EXCEPTIONS) - if(HAVE_OBJC_EXCEPTIONS) - foreach(source ${OPENCV_MODULE_${the_module}_SOURCES}) - if("${source}" MATCHES "\\.mm$") - get_source_file_property(flags "${source}" COMPILE_FLAGS) - if(flags) - set(flags "${_flags} -fobjc-exceptions") - else() - set(flags "-fobjc-exceptions") - endif() - - set_source_files_properties("${source}" PROPERTIES COMPILE_FLAGS "${flags}") - endif() - endforeach() - endif() + add_apple_compiler_options(the_module) endif() if(BUILD_SHARED_LIBS) diff --git a/modules/imgcodecs/src/grfmt_tiff.cpp b/modules/imgcodecs/src/grfmt_tiff.cpp index 00e1d30f331b575257f365007b89cb2be27e2eeb..7ec76c8483be6d6e877ecd453344cf17ab702e36 100644 --- a/modules/imgcodecs/src/grfmt_tiff.cpp +++ b/modules/imgcodecs/src/grfmt_tiff.cpp @@ -52,10 +52,11 @@ namespace cv { static const char fmtSignTiffII[] = "II\x2a\x00"; -static const char fmtSignTiffMM[] = "MM\x00\x2a"; #ifdef HAVE_TIFF +static const char fmtSignTiffMM[] = "MM\x00\x2a"; + #include "tiff.h" #include "tiffio.h" diff --git a/modules/imgcodecs/src/ios_conversions.mm b/modules/imgcodecs/src/ios_conversions.mm index af522900c81d55eb977b7770a43aafad665d0a22..c191ffeaecf04d77cb7cccd663a8e4b30d681f19 100644 --- a/modules/imgcodecs/src/ios_conversions.mm +++ b/modules/imgcodecs/src/ios_conversions.mm @@ -47,6 +47,9 @@ #include "opencv2/core.hpp" #include "precomp.hpp" +UIImage* MatToUIImage(const cv::Mat& image); +void UIImageToMat(const UIImage* image, cv::Mat& m, bool alphaExist); + UIImage* MatToUIImage(const cv::Mat& image) { NSData *data = [NSData dataWithBytes:image.data diff --git a/modules/imgproc/src/demosaicing.cpp b/modules/imgproc/src/demosaicing.cpp index 01a84ee8ede6ffed98adefeb16a024fb7d64cf3f..0b7afb8ea63ef864513310dc0d5af917208a5e9c 100644 --- a/modules/imgproc/src/demosaicing.cpp +++ b/modules/imgproc/src/demosaicing.cpp @@ -368,7 +368,8 @@ public: uint16x8_t g0 = vaddq_u16(vshrq_n_u16(r0, 8), vshrq_n_u16(r2, 8)); uint16x8_t g1 = vandq_u16(r1, masklo); g0 = vaddq_u16(g0, vaddq_u16(g1, vextq_u16(g1, g1, 1))); - g1 = vshlq_n_u16(vextq_u16(g1, g1, 1), 2); + uint16x8_t rot = vextq_u16(g1, g1, 1); + g1 = vshlq_n_u16(rot, 2); // g0 = b0 b2 b4 ... // g1 = b1 b3 b5 ... diff --git a/modules/imgproc/src/pyramids.cpp b/modules/imgproc/src/pyramids.cpp index c54dfd3aea736d69e0de1f1c77d5db4f69360a02..164ae50161b4d9cd02568b8d2d5bcc5530b5ac09 100644 --- a/modules/imgproc/src/pyramids.cpp +++ b/modules/imgproc/src/pyramids.cpp @@ -240,14 +240,18 @@ struct PyrDownVec_32s16u int32x4_t v_r20 = vld1q_s32(row2 + x), v_r21 = vld1q_s32(row2 + x + 4); int32x4_t v_r30 = vld1q_s32(row3 + x), v_r31 = vld1q_s32(row3 + x + 4); int32x4_t v_r40 = vld1q_s32(row4 + x), v_r41 = vld1q_s32(row4 + x + 4); + int32x4_t shifted; v_r00 = vaddq_s32(vqaddq_s32(v_r00, v_r40), vqaddq_s32(v_r20, v_r20)); v_r10 = vaddq_s32(vqaddq_s32(v_r10, v_r20), v_r30); - int32x4_t v_dst0 = vshrq_n_s32(vaddq_s32(vqaddq_s32(v_r00, vshlq_n_s32(v_r10, 2)), v_delta), 8); + + shifted = vshlq_n_s32(v_r10, 2); + int32x4_t v_dst0 = vshrq_n_s32(vaddq_s32(vqaddq_s32(v_r00, shifted), v_delta), 8); v_r01 = vaddq_s32(vqaddq_s32(v_r01, v_r41), vqaddq_s32(v_r21, v_r21)); v_r11 = vaddq_s32(vqaddq_s32(v_r11, v_r21), v_r31); - int32x4_t v_dst1 = vshrq_n_s32(vaddq_s32(vqaddq_s32(v_r01, vshlq_n_s32(v_r11, 2)), v_delta), 8); + shifted = vshlq_n_s32(v_r11, 2); + int32x4_t v_dst1 = vshrq_n_s32(vaddq_s32(vqaddq_s32(v_r01, shifted), v_delta), 8); vst1q_u16(dst + x, vcombine_u16(vqmovun_s32(v_dst0), vqmovun_s32(v_dst1))); } @@ -271,14 +275,17 @@ struct PyrDownVec_32s16s int32x4_t v_r20 = vld1q_s32(row2 + x), v_r21 = vld1q_s32(row2 + x + 4); int32x4_t v_r30 = vld1q_s32(row3 + x), v_r31 = vld1q_s32(row3 + x + 4); int32x4_t v_r40 = vld1q_s32(row4 + x), v_r41 = vld1q_s32(row4 + x + 4); + int32x4_t shifted; v_r00 = vaddq_s32(vqaddq_s32(v_r00, v_r40), vqaddq_s32(v_r20, v_r20)); v_r10 = vaddq_s32(vqaddq_s32(v_r10, v_r20), v_r30); - int32x4_t v_dst0 = vshrq_n_s32(vaddq_s32(vqaddq_s32(v_r00, vshlq_n_s32(v_r10, 2)), v_delta), 8); + shifted = vshlq_n_s32(v_r10, 2); + int32x4_t v_dst0 = vshrq_n_s32(vaddq_s32(vqaddq_s32(v_r00, shifted), v_delta), 8); v_r01 = vaddq_s32(vqaddq_s32(v_r01, v_r41), vqaddq_s32(v_r21, v_r21)); v_r11 = vaddq_s32(vqaddq_s32(v_r11, v_r21), v_r31); - int32x4_t v_dst1 = vshrq_n_s32(vaddq_s32(vqaddq_s32(v_r01, vshlq_n_s32(v_r11, 2)), v_delta), 8); + shifted = vshlq_n_s32(v_r11, 2); + int32x4_t v_dst1 = vshrq_n_s32(vaddq_s32(vqaddq_s32(v_r01, shifted), v_delta), 8); vst1q_s16(dst + x, vcombine_s16(vqmovn_s32(v_dst0), vqmovn_s32(v_dst1))); } diff --git a/modules/objdetect/src/haar.cpp b/modules/objdetect/src/haar.cpp index b4256111dd6f6987d93fa0c3e352c27f55f32a09..09928264ab3e046432179f16764058f772e570f8 100644 --- a/modules/objdetect/src/haar.cpp +++ b/modules/objdetect/src/haar.cpp @@ -1979,7 +1979,7 @@ cvLoadHaarClassifierCascade( const char* directory, CvSize orig_window_size ) if( !f ) CV_Error( CV_StsError, "" ); fseek( f, 0, SEEK_END ); - size = ftell( f ); + size = (int)ftell( f ); fseek( f, 0, SEEK_SET ); size_t elements_read = fread( ptr, 1, size, f ); CV_Assert(elements_read == (size_t)(size)); diff --git a/modules/stitching/src/matchers.cpp b/modules/stitching/src/matchers.cpp index 5922f1ba19344a0ddf40e0989803c2c0790d601b..49ee0f4744f4cdaaa2b1cf7138b1d9f2f99a356e 100644 --- a/modules/stitching/src/matchers.cpp +++ b/modules/stitching/src/matchers.cpp @@ -350,6 +350,11 @@ SurfFeaturesFinder::SurfFeaturesFinder(double hess_thresh, int num_octaves, int extractor_ = sextractor_; } #else + (void)hess_thresh; + (void)num_octaves; + (void)num_layers; + (void)num_octaves_descr; + (void)num_layers_descr; CV_Error( Error::StsNotImplemented, "OpenCV was built without SURF support" ); #endif } diff --git a/modules/videoio/CMakeLists.txt b/modules/videoio/CMakeLists.txt index 7c8f6a058f0c30dcfbb58a93369e8d675cd0d867..1635e2022fe664c81e93ae2d04158d9b585a6f82 100644 --- a/modules/videoio/CMakeLists.txt +++ b/modules/videoio/CMakeLists.txt @@ -189,21 +189,7 @@ ocv_create_module(${VIDEOIO_LIBRARIES}) macro(ocv_videoio_configure_target) if(APPLE) - ocv_check_flag_support(OBJCXX "-fobjc-exceptions" HAVE_OBJC_EXCEPTIONS) - if(HAVE_OBJC_EXCEPTIONS) - foreach(source ${OPENCV_MODULE_${the_module}_SOURCES}) - if("${source}" MATCHES "\\.mm$") - get_source_file_property(flags "${source}" COMPILE_FLAGS) - if(flags) - set(flags "${_flags} -fobjc-exceptions") - else() - set(flags "-fobjc-exceptions") - endif() - - set_source_files_properties("${source}" PROPERTIES COMPILE_FLAGS "${flags}") - endif() - endforeach() - endif() + add_apple_compiler_options(the_module) endif() if(BUILD_SHARED_LIBS) diff --git a/modules/videoio/src/cap_avfoundation.mm b/modules/videoio/src/cap_avfoundation.mm index e66f03a8da447c41cc50d0239741aa5267fe9fd3..29aeeb1c8507e15b3179fa781e069c32a1e86f81 100644 --- a/modules/videoio/src/cap_avfoundation.mm +++ b/modules/videoio/src/cap_avfoundation.mm @@ -181,7 +181,6 @@ class CvVideoWriter_AVFoundation : public CvVideoWriter{ AVAssetWriterInput* mMovieWriterInput; AVAssetWriterInputPixelBufferAdaptor* mMovieWriterAdaptor; - unsigned char* imagedata; NSString* path; NSString* codec; NSString* fileType; @@ -490,15 +489,15 @@ double CvCaptureCAM::getProperty(int property_id){ CMFormatDescriptionRef format = [[ports objectAtIndex:0] formatDescription]; CGSize s1 = CMVideoFormatDescriptionGetPresentationDimensions(format, YES, YES); - int width=(int)s1.width, height=(int)s1.height; + int w=(int)s1.width, h=(int)s1.height; [localpool drain]; switch (property_id) { case CV_CAP_PROP_FRAME_WIDTH: - return width; + return w; case CV_CAP_PROP_FRAME_HEIGHT: - return height; + return h; case CV_CAP_PROP_IOS_DEVICE_FOCUS: return mCaptureDevice.focusMode; @@ -659,6 +658,8 @@ fromConnection:(AVCaptureConnection *)connection{ // Failed // connection.videoOrientation = AVCaptureVideoOrientationPortrait; + (void)captureOutput; + (void)connection; CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); @@ -710,26 +711,26 @@ fromConnection:(AVCaptureConnection *)connection{ memcpy(imagedata, baseaddress, currSize); if (image == NULL) { - image = cvCreateImageHeader(cvSize(width,height), IPL_DEPTH_8U, 4); + image = cvCreateImageHeader(cvSize((int)width,(int)height), IPL_DEPTH_8U, 4); } - image->width =width; - image->height = height; + image->width = (int)width; + image->height = (int)height; image->nChannels = 4; image->depth = IPL_DEPTH_8U; image->widthStep = (int)rowBytes; image->imageData = imagedata; - image->imageSize = currSize; + image->imageSize = (int)currSize; if (bgr_image == NULL) { - bgr_image = cvCreateImageHeader(cvSize(width,height), IPL_DEPTH_8U, 3); + bgr_image = cvCreateImageHeader(cvSize((int)width,(int)height), IPL_DEPTH_8U, 3); } - bgr_image->width =width; - bgr_image->height = height; + bgr_image->width = (int)width; + bgr_image->height = (int)height; bgr_image->nChannels = 3; bgr_image->depth = IPL_DEPTH_8U; bgr_image->widthStep = (int)rowBytes; bgr_image->imageData = bgr_imagedata; - bgr_image->imageSize = currSize; + bgr_image->imageSize = (int)currSize; cvCvtColor(image, bgr_image, CV_BGRA2BGR); @@ -738,7 +739,7 @@ fromConnection:(AVCaptureConnection *)connection{ // iOS provides hardware accelerated rotation through AVCaptureConnection class // I can't get it work. if (bgr_image_r90 == NULL){ - bgr_image_r90 = cvCreateImage(cvSize(height, width), IPL_DEPTH_8U, 3); + bgr_image_r90 = cvCreateImage(cvSize((int)height, (int)width), IPL_DEPTH_8U, 3); } cvTranspose(bgr_image, bgr_image_r90); cvFlip(bgr_image_r90, NULL, 1); @@ -938,29 +939,29 @@ IplImage* CvCaptureFile::retrieveFramePixelBuffer() { memcpy(imagedata, baseaddress, currSize); if (image == NULL) { - image = cvCreateImageHeader(cvSize(width,height), IPL_DEPTH_8U, 4); + image = cvCreateImageHeader(cvSize((int)width,(int)height), IPL_DEPTH_8U, 4); } - image->width =width; - image->height = height; + image->width = (int)width; + image->height = (int)height; image->nChannels = 4; image->depth = IPL_DEPTH_8U; - image->widthStep = rowBytes; + image->widthStep = (int)rowBytes; image->imageData = imagedata; - image->imageSize = currSize; + image->imageSize = (int)currSize; if (bgr_image == NULL) { - bgr_image = cvCreateImageHeader(cvSize(width,height), IPL_DEPTH_8U, 3); + bgr_image = cvCreateImageHeader(cvSize((int)width,(int)height), IPL_DEPTH_8U, 3); } - bgr_image->width =width; - bgr_image->height = height; + bgr_image->width = (int)width; + bgr_image->height = (int)height; bgr_image->nChannels = 3; bgr_image->depth = IPL_DEPTH_8U; - bgr_image->widthStep = rowBytes; + bgr_image->widthStep = (int)rowBytes; bgr_image->imageData = bgr_imagedata; - bgr_image->imageSize = currSize; + bgr_image->imageSize = (int)currSize; cvCvtColor(image, bgr_image,CV_BGRA2BGR); @@ -1009,7 +1010,7 @@ double CvCaptureFile::getFPS() { return 30.0; //TODO: Debugging } -double CvCaptureFile::getProperty(int property_id){ +double CvCaptureFile::getProperty(int /*property_id*/){ /* if (mCaptureSession == nil) return 0; @@ -1050,7 +1051,7 @@ double CvCaptureFile::getProperty(int property_id){ return 1.0; //Debugging } -bool CvCaptureFile::setProperty(int property_id, double value) { +bool CvCaptureFile::setProperty(int /*property_id*/, double /*value*/) { /* if (mCaptureSession == nil) return false; @@ -1261,7 +1262,7 @@ bool CvVideoWriter_AVFoundation::writeFrame(const IplImage* iplimage) { // writer status check if (![mMovieWriterInput isReadyForMoreMediaData] || mMovieWriter.status != AVAssetWriterStatusWriting ) { NSLog(@"[mMovieWriterInput isReadyForMoreMediaData] Not ready for media data or ..."); - NSLog(@"mMovieWriter.status: %d. Error: %@", mMovieWriter.status, [mMovieWriter.error localizedDescription]); + NSLog(@"mMovieWriter.status: %d. Error: %@", (int)mMovieWriter.status, [mMovieWriter.error localizedDescription]); [localpool drain]; return false; } diff --git a/modules/videoio/src/cap_ios_abstract_camera.mm b/modules/videoio/src/cap_ios_abstract_camera.mm index 08547663cac54959ea833b8d27c7b3d4ec6deba0..1ded46a99f18b4343257689728d176c57fde186b 100644 --- a/modules/videoio/src/cap_ios_abstract_camera.mm +++ b/modules/videoio/src/cap_ios_abstract_camera.mm @@ -150,6 +150,7 @@ { [[NSNotificationCenter defaultCenter] removeObserver:self]; [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; + [super dealloc]; } @@ -226,6 +227,7 @@ - (void)deviceOrientationDidChange:(NSNotification*)notification { + (void)notification; UIDeviceOrientation orientation = [UIDevice currentDevice].orientation; switch (orientation) @@ -242,7 +244,7 @@ default: break; } - NSLog(@"deviceOrientationDidChange: %d", orientation); + NSLog(@"deviceOrientationDidChange: %d", (int)orientation); [self updateOrientation]; } @@ -308,7 +310,7 @@ if ([device position] == desiredPosition) { [self.captureSession beginConfiguration]; - NSError* error; + NSError* error = nil; AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error]; if (!input) { NSLog(@"error creating input %@", [error localizedDescription]); @@ -316,7 +318,7 @@ // support for autofocus if ([device isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus]) { - NSError *error = nil; + error = nil; if ([device lockForConfiguration:&error]) { device.focusMode = AVCaptureFocusModeContinuousAutoFocus; [device unlockForConfiguration]; diff --git a/modules/videoio/src/cap_ios_video_camera.mm b/modules/videoio/src/cap_ios_video_camera.mm index c094de79c1bece308797c52d2d694459105ab714..152fc8064396db49f53fd0ccad03c65874887957 100644 --- a/modules/videoio/src/cap_ios_video_camera.mm +++ b/modules/videoio/src/cap_ios_video_camera.mm @@ -101,7 +101,7 @@ static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;} [super start]; if (self.recordVideo == YES) { - NSError* error; + NSError* error = nil; if ([[NSFileManager defaultManager] fileExistsAtPath:[self videoFileString]]) { [[NSFileManager defaultManager] removeItemAtPath:[self videoFileString] error:&error]; } @@ -424,6 +424,8 @@ static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;} - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection { + (void)captureOutput; + (void)connection; if (self.delegate) { // convert from Core Media to Core Video @@ -462,9 +464,8 @@ static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;} } // delegate image processing to the delegate - cv::Mat image(height, width, format_opencv, bufferAddress, bytesPerRow); + cv::Mat image((int)height, (int)width, format_opencv, bufferAddress, bytesPerRow); - cv::Mat* result = NULL; CGImage* dstImage; if ([self.delegate respondsToSelector:@selector(processImage:)]) { @@ -473,7 +474,7 @@ static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;} // check if matrix data pointer or dimensions were changed by the delegate bool iOSimage = false; - if (height == image.rows && width == image.cols && format_opencv == image.type() && bufferAddress == image.data && bytesPerRow == image.step) { + if (height == (size_t)image.rows && width == (size_t)image.cols && format_opencv == image.type() && bufferAddress == image.data && bytesPerRow == image.step) { iOSimage = true; } @@ -591,7 +592,7 @@ static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;} ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:[self videoFileURL]]) { [library writeVideoAtPathToSavedPhotosAlbum:[self videoFileURL] - completionBlock:^(NSURL *assetURL, NSError *error){}]; + completionBlock:^(NSURL *assetURL, NSError *error){ (void)assetURL; (void)error; }]; } } diff --git a/platforms/ios/build_framework.py b/platforms/ios/build_framework.py index e28dc6d88026e5f1901453244f08445feb8c24f5..28ce885b206f11b139f56982a200746fc771a7fa 100755 --- a/platforms/ios/build_framework.py +++ b/platforms/ios/build_framework.py @@ -25,7 +25,18 @@ The script should handle minor OpenCV updates efficiently However, opencv2.framework directory is erased and recreated on each run. """ -import glob, re, os, os.path, shutil, string, sys +import glob, re, os, os.path, shutil, string, sys, exceptions, subprocess + +def execute(cmd): + try: + print >>sys.stderr, "Executing:", cmd + retcode = subprocess.call(cmd, shell=True) + if retcode < 0: + raise Exception("Child was terminated by signal:", -retcode) + elif retcode > 0: + raise Exception("Child returned:", retcode) + except OSError as e: + raise Exception("Execution failed:", e) def build_opencv(srcroot, buildroot, target, arch): "builds OpenCV for device or simulator" @@ -48,17 +59,17 @@ def build_opencv(srcroot, buildroot, target, arch): # if cmake cache exists, just rerun cmake to update OpenCV.xcodeproj if necessary if os.path.isfile(os.path.join(builddir, "CMakeCache.txt")): - os.system("cmake %s ." % (cmakeargs,)) + execute("cmake %s ." % (cmakeargs,)) else: - os.system("cmake %s %s" % (cmakeargs, srcroot)) + execute("cmake %s %s" % (cmakeargs, srcroot)) for wlib in [builddir + "/modules/world/UninstalledProducts/libopencv_world.a", builddir + "/lib/Release/libopencv_world.a"]: if os.path.isfile(wlib): os.remove(wlib) - os.system("xcodebuild IPHONEOS_DEPLOYMENT_TARGET=6.0 -parallelizeTargets ARCHS=%s -jobs 8 -sdk %s -configuration Release -target ALL_BUILD" % (arch, target.lower())) - os.system("xcodebuild IPHONEOS_DEPLOYMENT_TARGET=6.0 ARCHS=%s -sdk %s -configuration Release -target install install" % (arch, target.lower())) + execute("xcodebuild IPHONEOS_DEPLOYMENT_TARGET=6.0 -parallelizeTargets ARCHS=%s -jobs 8 -sdk %s -configuration Release -target ALL_BUILD" % (arch, target.lower())) + execute("xcodebuild IPHONEOS_DEPLOYMENT_TARGET=6.0 ARCHS=%s -sdk %s -configuration Release -target install install" % (arch, target.lower())) os.chdir(currdir) def put_framework_together(srcroot, dstroot): @@ -86,7 +97,7 @@ def put_framework_together(srcroot, dstroot): # make universal static lib wlist = " ".join(["../build/" + t + "/lib/Release/libopencv_world.a" for t in targetlist]) - os.system("lipo -create " + wlist + " -o " + dstdir + "/opencv2") + execute("lipo -create " + wlist + " -o " + dstdir + "/opencv2") # copy Info.plist shutil.copyfile(tdir0 + "/ios/Info.plist", dstdir + "/Resources/Info.plist") @@ -101,10 +112,13 @@ def put_framework_together(srcroot, dstroot): def build_framework(srcroot, dstroot): "main function to do all the work" - targets = ["iPhoneOS", "iPhoneOS", "iPhoneOS", "iPhoneSimulator", "iPhoneSimulator"] - archs = ["armv7", "armv7s", "arm64", "i386", "x86_64"] - for i in range(len(targets)): - build_opencv(srcroot, os.path.join(dstroot, "build"), targets[i], archs[i]) + targets = [("armv7", "iPhoneOS"), + ("armv7s", "iPhoneOS"), + ("arm64", "iPhoneOS"), + ("i386", "iPhoneSimulator"), + ("x86_64", "iPhoneSimulator")] + for t in targets: + build_opencv(srcroot, os.path.join(dstroot, "build"), t[1], t[0]) put_framework_together(srcroot, dstroot) @@ -114,4 +128,8 @@ if __name__ == "__main__": print "Usage:\n\t./build_framework.py \n\n" sys.exit(0) - build_framework(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "../..")), os.path.abspath(sys.argv[1])) + try: + build_framework(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "../..")), os.path.abspath(sys.argv[1])) + except Exception as e: + print >>sys.stderr, e + sys.exit(1) diff --git a/platforms/ios/cmake/Modules/Platform/iOS.cmake b/platforms/ios/cmake/Modules/Platform/iOS.cmake index e021aca55f7825eefbcf24b1c2b1e0ff938bb837..3a80e84ae10e5559770b9816b2db6c77fa23d3ae 100644 --- a/platforms/ios/cmake/Modules/Platform/iOS.cmake +++ b/platforms/ios/cmake/Modules/Platform/iOS.cmake @@ -39,8 +39,9 @@ set (CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSI set (CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}") # Hidden visibilty is required for cxx on iOS -set (CMAKE_C_FLAGS "") -set (CMAKE_CXX_FLAGS "-stdlib=libc++ -headerpad_max_install_names -fvisibility=hidden -fvisibility-inlines-hidden") +set (no_warn "-Wno-unused-function -Wno-overloaded-virtual") +set (CMAKE_C_FLAGS "${no_warn}") +set (CMAKE_CXX_FLAGS "-stdlib=libc++ -fvisibility=hidden -fvisibility-inlines-hidden ${no_warn}") set (CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3 -fomit-frame-pointer -ffast-math")