From ef3d02214bc959caed9483ec60fc35f92f7f1040 Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Fri, 17 Oct 2014 16:32:53 +0400 Subject: [PATCH] Fixing iOS clang warnings, part 2 --- cmake/OpenCVUtils.cmake | 4 +- modules/core/src/parallel.cpp | 2 +- modules/core/src/persistence.cpp | 4 +- modules/objdetect/src/haar.cpp | 2 +- modules/videoio/src/cap_avfoundation.mm | 40 +++++++++---------- .../videoio/src/cap_ios_abstract_camera.mm | 2 + modules/videoio/src/cap_ios_video_camera.mm | 4 +- .../ios/cmake/Modules/Platform/iOS.cmake | 2 +- 8 files changed, 31 insertions(+), 29 deletions(-) diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake index b32465ead2..435742dc39 100644 --- a/cmake/OpenCVUtils.cmake +++ b/cmake/OpenCVUtils.cmake @@ -249,9 +249,9 @@ macro(add_apple_compiler_options the_module) if("${source}" MATCHES "\\.mm$") get_source_file_property(flags "${source}" COMPILE_FLAGS) if(flags) - set(flags "${_flags} -fobjc-exceptions") + set(flags "${_flags} -fobjc-exceptions -Wno-semicolon-before-method-body") else() - set(flags "-fobjc-exceptions") + set(flags "-fobjc-exceptions -Wno-semicolon-before-method-body") endif() set_source_files_properties("${source}" PROPERTIES COMPILE_FLAGS "${flags}") diff --git a/modules/core/src/parallel.cpp b/modules/core/src/parallel.cpp index 6ebc02df2c..5a51230cef 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 8ee97273e8..fb5648d06f 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/objdetect/src/haar.cpp b/modules/objdetect/src/haar.cpp index b4256111dd..09928264ab 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/videoio/src/cap_avfoundation.mm b/modules/videoio/src/cap_avfoundation.mm index f52700d3b0..29aeeb1c85 100644 --- a/modules/videoio/src/cap_avfoundation.mm +++ b/modules/videoio/src/cap_avfoundation.mm @@ -711,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); @@ -739,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); @@ -939,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); @@ -1262,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 6af40459ad..3748d910a4 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) diff --git a/modules/videoio/src/cap_ios_video_camera.mm b/modules/videoio/src/cap_ios_video_camera.mm index 4d05f673ae..a75d7b44ed 100644 --- a/modules/videoio/src/cap_ios_video_camera.mm +++ b/modules/videoio/src/cap_ios_video_camera.mm @@ -474,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; } @@ -592,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/cmake/Modules/Platform/iOS.cmake b/platforms/ios/cmake/Modules/Platform/iOS.cmake index 0db95fb17b..a1ecdeaf3c 100644 --- a/platforms/ios/cmake/Modules/Platform/iOS.cmake +++ b/platforms/ios/cmake/Modules/Platform/iOS.cmake @@ -44,7 +44,7 @@ set (CMAKE_CXX_FLAGS "-stdlib=libc++ -fvisibility=hidden -fvisibility-inlines-hi set (CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3 -fomit-frame-pointer -ffast-math") # Silence some warnings -set (no_warn "-Wno-semicolon-before-method-body -Wno-unused-function -Wno-unused-parameter -Wno-strict-prototypes -Wno-missing-prototypes -Wno-missing-declarations -Wno-unused-const-variable -Wno-overloaded-virtual") +set (no_warn "-Wno-unused-function -Wno-unused-parameter -Wno-strict-prototypes -Wno-missing-prototypes -Wno-missing-declarations -Wno-unused-const-variable -Wno-overloaded-virtual") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${no_warn}") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${no_warn}") # Additional linker flag