From 420737e09891b1b176638864ea4000dd033d0d11 Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Fri, 17 Oct 2014 15:45:13 +0400 Subject: [PATCH] Fixing iOS clang warnings, part 1 --- modules/imgcodecs/src/ios_conversions.mm | 3 +++ modules/imgproc/src/demosaicing.cpp | 3 ++- modules/imgproc/src/pyramids.cpp | 15 +++++++++++---- modules/videoio/src/cap_avfoundation.mm | 13 +++++++------ modules/videoio/src/cap_ios_abstract_camera.mm | 4 ++-- modules/videoio/src/cap_ios_video_camera.mm | 5 +++-- platforms/ios/cmake/Modules/Platform/iOS.cmake | 2 +- 7 files changed, 29 insertions(+), 16 deletions(-) diff --git a/modules/imgcodecs/src/ios_conversions.mm b/modules/imgcodecs/src/ios_conversions.mm index af522900c..c191ffeae 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 01a84ee8e..e894710cd 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 c54dfd3ae..15ff1ac34 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/videoio/src/cap_avfoundation.mm b/modules/videoio/src/cap_avfoundation.mm index e66f03a8d..f52700d3b 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); @@ -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; diff --git a/modules/videoio/src/cap_ios_abstract_camera.mm b/modules/videoio/src/cap_ios_abstract_camera.mm index 08547663c..6af40459a 100644 --- a/modules/videoio/src/cap_ios_abstract_camera.mm +++ b/modules/videoio/src/cap_ios_abstract_camera.mm @@ -308,7 +308,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 +316,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 c094de79c..4d05f673a 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 @@ -464,7 +466,6 @@ 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* result = NULL; CGImage* dstImage; if ([self.delegate respondsToSelector:@selector(processImage:)]) { diff --git a/platforms/ios/cmake/Modules/Platform/iOS.cmake b/platforms/ios/cmake/Modules/Platform/iOS.cmake index a1ecdeaf3..0db95fb17 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-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-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 (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${no_warn}") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${no_warn}") # Additional linker flag