diff --git a/modules/core/include/opencv2/core/core_c.h b/modules/core/include/opencv2/core/core_c.h index c8c9d2eb02..ce28fa1bef 100644 --- a/modules/core/include/opencv2/core/core_c.h +++ b/modules/core/include/opencv2/core/core_c.h @@ -1978,11 +1978,7 @@ The function opens file storage for reading or writing data. In the latter case, created or an existing file is rewritten. The type of the read or written file is determined by the filename extension: .xml for XML, .yml or .yaml for YAML and .json for JSON. -At the same time, it also supports adding parameters like "example.xml?base64". The three ways -are the same: -@snippet samples/cpp/filestorage_base64.cpp suffix_in_file_name -@snippet samples/cpp/filestorage_base64.cpp flag_write_base64 -@snippet samples/cpp/filestorage_base64.cpp flag_write_and_flag_base64 +At the same time, it also supports adding parameters like "example.xml?base64". The function returns a pointer to the CvFileStorage structure. If the file cannot be opened then the function returns NULL. @@ -2206,11 +2202,6 @@ in plain text. This function can only be used to write a sequence with a type "binary". -Consider the following two examples where their output is the same: -@snippet samples/cpp/filestorage_base64.cpp without_base64_flag -and -@snippet samples/cpp/filestorage_base64.cpp with_write_base64_flag - @param fs File storage @param src Pointer to the written array @param len Number of the array elements to write diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index 1f2fc96772..b93a10c0d9 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -4339,6 +4339,10 @@ CV_EXPORTS_W void applyColorMap(InputArray src, OutputArray dst, InputArray user //! @addtogroup imgproc_draw //! @{ + +/** OpenCV color channel order is BGR[A] */ +#define CV_RGB(r, g, b) cv::Scalar((b), (g), (r), 0) + /** @brief Draws a line segment connecting two points. The function line draws the line segment between pt1 and pt2 points in the image. The line is diff --git a/modules/imgproc/include/opencv2/imgproc/imgproc_c.h b/modules/imgproc/include/opencv2/imgproc/imgproc_c.h index d11db4b258..fadb8820b7 100644 --- a/modules/imgproc/include/opencv2/imgproc/imgproc_c.h +++ b/modules/imgproc/include/opencv2/imgproc/imgproc_c.h @@ -982,7 +982,6 @@ CVAPI(void) cvFitLine( const CvArr* points, int dist_type, double param, * If a drawn figure is partially or completely outside of the image, it is clipped.* \****************************************************************************************/ -#define CV_RGB( r, g, b ) cvScalar( (b), (g), (r), 0 ) #define CV_FILLED -1 #define CV_AA 16 diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index e6ecdf826a..45dae6a5ad 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -125,6 +125,8 @@ if(MSVC) endif() endif() +add_definitions(-DDISABLE_OPENCV_24_COMPATIBILITY=1) # Avoid C-like legacy API + add_subdirectory(cpp) if(WIN32) add_subdirectory(directx) diff --git a/samples/cpp/autofocus.cpp b/samples/cpp/autofocus.cpp index a71a2954f2..d0baa315bf 100644 --- a/samples/cpp/autofocus.cpp +++ b/samples/cpp/autofocus.cpp @@ -133,7 +133,7 @@ static double rateFrame(Mat & frame) unsigned long int sum = 0; unsigned long int size = frame.cols * frame.rows; Mat edges; - cvtColor(frame, edges, CV_BGR2GRAY); + cvtColor(frame, edges, COLOR_BGR2GRAY); GaussianBlur(edges, edges, Size(7, 7), 1.5, 1.5); Canny(edges, edges, 0, 30, 3); @@ -324,7 +324,7 @@ int main(int argc, char ** argv) if (!GlobalArgs.output.empty()) { Size S = Size((int) cap.get(CAP_PROP_FRAME_WIDTH), (int) cap.get(CAP_PROP_FRAME_HEIGHT)); - int fourCC = CV_FOURCC('M', 'J', 'P', 'G'); + int fourCC = VideoWriter::fourcc('M', 'J', 'P', 'G'); videoWriter.open(GlobalArgs.output, fourCC, GlobalArgs.fps, S, true); if (!videoWriter.isOpened()) { diff --git a/samples/cpp/facedetect.cpp b/samples/cpp/facedetect.cpp index ff985e6ec7..f6de738d43 100644 --- a/samples/cpp/facedetect.cpp +++ b/samples/cpp/facedetect.cpp @@ -218,8 +218,8 @@ void detectAndDraw( Mat& img, CascadeClassifier& cascade, circle( img, center, radius, color, 3, 8, 0 ); } else - rectangle( img, cvPoint(cvRound(r.x*scale), cvRound(r.y*scale)), - cvPoint(cvRound((r.x + r.width-1)*scale), cvRound((r.y + r.height-1)*scale)), + rectangle( img, Point(cvRound(r.x*scale), cvRound(r.y*scale)), + Point(cvRound((r.x + r.width-1)*scale), cvRound((r.y + r.height-1)*scale)), color, 3, 8, 0); if( nestedCascade.empty() ) continue; diff --git a/samples/cpp/filestorage_base64.cpp b/samples/cpp/filestorage_base64.cpp deleted file mode 100644 index dcd46544f9..0000000000 --- a/samples/cpp/filestorage_base64.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "opencv2/core.hpp" -#include -#include - -static CvFileStorage * three_same_ways_of_write_base64() -{ - CvFileStorage * fs = 0; - cv::RNG rng; - switch ( rng.uniform( 0, 2 ) ) - { - case 0: - //! [suffix_in_file_name] - fs = cvOpenFileStorage( "example.yml?base64", 0, CV_STORAGE_WRITE ); - //! [suffix_in_file_name] - break; - case 1: - //! [flag_write_base64] - fs = cvOpenFileStorage( "example.yml" , 0, CV_STORAGE_WRITE_BASE64 ); - //! [flag_write_base64] - break; - case 2: - //! [flag_write_and_flag_base64] - fs = cvOpenFileStorage( "example.yml" , 0, CV_STORAGE_WRITE | CV_STORAGE_BASE64 ); - //! [flag_write_and_flag_base64] - break; - default: - break; - } - return fs; -} - -static void two_ways_to_write_rawdata_in_base64() -{ - std::vector rawdata(10, 0x00010203); - - { // [1] - //! [without_base64_flag] - CvFileStorage* fs = cvOpenFileStorage( "example.xml", 0, CV_STORAGE_WRITE ); - // both CV_NODE_SEQ and "binary" are necessary. - cvStartWriteStruct(fs, "rawdata", CV_NODE_SEQ | CV_NODE_FLOW, "binary"); - cvWriteRawDataBase64(fs, rawdata.data(), static_cast(rawdata.size()), "i"); - cvEndWriteStruct(fs); - cvReleaseFileStorage( &fs ); - //! [without_base64_flag] - } - - { // [2] - //! [with_write_base64_flag] - CvFileStorage* fs = cvOpenFileStorage( "example.xml", 0, CV_STORAGE_WRITE_BASE64); - // parameter, typename "binary" could be omitted. - cvStartWriteStruct(fs, "rawdata", CV_NODE_SEQ | CV_NODE_FLOW); - cvWriteRawData(fs, rawdata.data(), static_cast(rawdata.size()), "i"); - cvEndWriteStruct(fs); - cvReleaseFileStorage( &fs ); - //! [with_write_base64_flag] - } -} - -int main(int /* argc */, char** /* argv */) -{ - { // base64 mode - CvFileStorage * fs = three_same_ways_of_write_base64(); - cvReleaseFileStorage( &fs ); - } - - { // output rawdata by `cvWriteRawdata*` - two_ways_to_write_rawdata_in_base64(); - } - - return 0; -} diff --git a/samples/cpp/fitellipse.cpp b/samples/cpp/fitellipse.cpp index 3ca4158c3e..8aaf0bae5c 100644 --- a/samples/cpp/fitellipse.cpp +++ b/samples/cpp/fitellipse.cpp @@ -207,7 +207,7 @@ int main( int argc, char** argv ) } imshow("source", image); - namedWindow("result", CV_WINDOW_NORMAL ); + namedWindow("result", WINDOW_NORMAL ); // Create toolbars. HighGUI use. createTrackbar( "threshold", "result", &sliderPos, 255, processImage ); diff --git a/samples/cpp/mask_tmpl.cpp b/samples/cpp/mask_tmpl.cpp index e2979a77c1..7216cbd842 100644 --- a/samples/cpp/mask_tmpl.cpp +++ b/samples/cpp/mask_tmpl.cpp @@ -50,7 +50,7 @@ int main( int argc, const char** argv ) Rect rect; minMaxLoc(res, &minVal, &maxVal, &minLoc, &maxLoc); - if(method == CV_TM_SQDIFF || method == CV_TM_SQDIFF_NORMED) + if(method == TM_SQDIFF || method == TM_SQDIFF_NORMED) rect = Rect(minLoc, tmpl.size()); else rect = Rect(maxLoc, tmpl.size()); diff --git a/samples/cpp/smiledetect.cpp b/samples/cpp/smiledetect.cpp index 94172b5933..a60d64283a 100644 --- a/samples/cpp/smiledetect.cpp +++ b/samples/cpp/smiledetect.cpp @@ -177,8 +177,8 @@ void detectAndDraw( Mat& img, CascadeClassifier& cascade, circle( img, center, radius, color, 3, 8, 0 ); } else - rectangle( img, cvPoint(cvRound(r.x*scale), cvRound(r.y*scale)), - cvPoint(cvRound((r.x + r.width-1)*scale), cvRound((r.y + r.height-1)*scale)), + rectangle( img, Point(cvRound(r.x*scale), cvRound(r.y*scale)), + Point(cvRound((r.x + r.width-1)*scale), cvRound((r.y + r.height-1)*scale)), color, 3, 8, 0); const int half_height=cvRound((float)r.height/2); @@ -206,7 +206,7 @@ void detectAndDraw( Mat& img, CascadeClassifier& cascade, float intensityZeroOne = ((float)smile_neighbors - min_neighbors) / (max_neighbors - min_neighbors + 1); int rect_height = cvRound((float)img.rows * intensityZeroOne); Scalar col = Scalar((float)255 * intensityZeroOne, 0, 0); - rectangle(img, cvPoint(0, img.rows), cvPoint(img.cols/10, img.rows - rect_height), col, -1); + rectangle(img, Point(0, img.rows), Point(img.cols/10, img.rows - rect_height), col, -1); } imshow( "result", img ); diff --git a/samples/cpp/train_HOG.cpp b/samples/cpp/train_HOG.cpp index 5b44de33d2..ad356c5f5b 100644 --- a/samples/cpp/train_HOG.cpp +++ b/samples/cpp/train_HOG.cpp @@ -312,7 +312,7 @@ int main( int argc, char** argv ) /* Default values to train SVM */ svm->setCoef0( 0.0 ); svm->setDegree( 3 ); - svm->setTermCriteria( TermCriteria( CV_TERMCRIT_ITER + CV_TERMCRIT_EPS, 1000, 1e-3 ) ); + svm->setTermCriteria( TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 1000, 1e-3 ) ); svm->setGamma( 0 ); svm->setKernel( SVM::LINEAR ); svm->setNu( 0.5 ); diff --git a/samples/cpp/train_svmsgd.cpp b/samples/cpp/train_svmsgd.cpp index 854be5c28d..bfd837d507 100644 --- a/samples/cpp/train_svmsgd.cpp +++ b/samples/cpp/train_svmsgd.cpp @@ -189,11 +189,11 @@ static void onMouse( int event, int x, int y, int, void* pData) switch( event ) { - case CV_EVENT_LBUTTONUP: + case EVENT_LBUTTONUP: addPointRetrainAndRedraw(data, x, y, 1); break; - case CV_EVENT_RBUTTONDOWN: + case EVENT_RBUTTONDOWN: addPointRetrainAndRedraw(data, x, y, -1); break; } diff --git a/samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp b/samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp index c60e45b154..f2f0ec03c5 100644 --- a/samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp +++ b/samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp @@ -97,7 +97,7 @@ void MatchingMethod( int, void* ) //! [match_template] /// Do the Matching and Normalize - bool method_accepts_mask = (CV_TM_SQDIFF == match_method || match_method == CV_TM_CCORR_NORMED); + bool method_accepts_mask = (TM_SQDIFF == match_method || match_method == TM_CCORR_NORMED); if (use_mask && method_accepts_mask) { matchTemplate( img, templ, result, match_method, mask); } else diff --git a/samples/cpp/tutorial_code/ImgProc/morph_lines_detection/Morphology_3.cpp b/samples/cpp/tutorial_code/ImgProc/morph_lines_detection/Morphology_3.cpp index 9ab0099282..ac10f9cff1 100644 --- a/samples/cpp/tutorial_code/ImgProc/morph_lines_detection/Morphology_3.cpp +++ b/samples/cpp/tutorial_code/ImgProc/morph_lines_detection/Morphology_3.cpp @@ -36,7 +36,7 @@ int main(int argc, char** argv) if (src.channels() == 3) { - cvtColor(src, gray, CV_BGR2GRAY); + cvtColor(src, gray, COLOR_BGR2GRAY); } else { @@ -50,7 +50,7 @@ int main(int argc, char** argv) //! [bin] // Apply adaptiveThreshold at the bitwise_not of gray, notice the ~ symbol Mat bw; - adaptiveThreshold(~gray, bw, 255, CV_ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, 15, -2); + adaptiveThreshold(~gray, bw, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, 15, -2); // Show binary image show_wait_destroy("binary", bw); @@ -106,7 +106,7 @@ int main(int argc, char** argv) // Step 1 Mat edges; - adaptiveThreshold(vertical, edges, 255, CV_ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, 3, -2); + adaptiveThreshold(vertical, edges, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, 3, -2); show_wait_destroy("edges", edges); // Step 2 diff --git a/samples/cpp/tutorial_code/ImgTrans/houghlines.cpp b/samples/cpp/tutorial_code/ImgTrans/houghlines.cpp index 8180b9d776..0211d6cde2 100644 --- a/samples/cpp/tutorial_code/ImgTrans/houghlines.cpp +++ b/samples/cpp/tutorial_code/ImgTrans/houghlines.cpp @@ -56,7 +56,7 @@ int main(int argc, char** argv) pt1.y = cvRound(y0 + 1000*(a)); pt2.x = cvRound(x0 - 1000*(-b)); pt2.y = cvRound(y0 - 1000*(a)); - line( cdst, pt1, pt2, Scalar(0,0,255), 3, CV_AA); + line( cdst, pt1, pt2, Scalar(0,0,255), 3, LINE_AA); } //![draw_lines] diff --git a/samples/cpp/videowriter_basic.cpp b/samples/cpp/videowriter_basic.cpp index 76f92ec0e0..3bfc08a2c3 100644 --- a/samples/cpp/videowriter_basic.cpp +++ b/samples/cpp/videowriter_basic.cpp @@ -35,7 +35,7 @@ int main(int, char**) //--- INITIALIZE VIDEOWRITER VideoWriter writer; - int codec = CV_FOURCC('M', 'J', 'P', 'G'); // select desired codec (must be available at runtime) + int codec = VideoWriter::fourcc('M', 'J', 'P', 'G'); // select desired codec (must be available at runtime) double fps = 25.0; // framerate of the created video stream string filename = "./live.avi"; // name of the output video file writer.open(filename, codec, fps, src.size(), isColor); diff --git a/samples/winrt/FaceDetection/FaceDetection/MainPage.xaml.cpp b/samples/winrt/FaceDetection/FaceDetection/MainPage.xaml.cpp index e0ec27ad61..dbf7fde351 100644 --- a/samples/winrt/FaceDetection/FaceDetection/MainPage.xaml.cpp +++ b/samples/winrt/FaceDetection/FaceDetection/MainPage.xaml.cpp @@ -63,7 +63,7 @@ void FaceDetection::MainPage::detectBtn_Click(Platform::Object^ sender, Windows: std::vector facesColl; cv::Mat frame_gray; - cvtColor(groupFaces, frame_gray, CV_BGR2GRAY); + cvtColor(groupFaces, frame_gray, COLOR_BGR2GRAY); cv::equalizeHist(frame_gray, frame_gray); // Detect faces