Skip to content

Commit

Permalink
Minimize usages of legacy C API inside the library
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Kamaev committed Apr 16, 2013
1 parent 4223a59 commit 8f32902
Show file tree
Hide file tree
Showing 45 changed files with 184 additions and 238 deletions.
2 changes: 1 addition & 1 deletion cmake/OpenCVDetectAndroidSDK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ macro(add_android_project target path)
ocv_include_modules_recurse(${android_proj_NATIVE_DEPS})
ocv_include_directories("${path}/jni")

if (NATIVE_APP_GLUE)
if (NATIVE_APP_GLUE AND 0)
include_directories(${ANDROID_NDK}/sources/android/native_app_glue)
list(APPEND android_proj_jni_files ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
ocv_warnings_disable(CMAKE_C_FLAGS -Wstrict-prototypes -Wunused-parameter -Wmissing-prototypes)
Expand Down
3 changes: 1 addition & 2 deletions doc/tutorials/core/adding_images/adding_images.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ As usual, after the not-so-lengthy explanation, let's go to the code:

.. code-block:: cpp
#include <cv.h>
#include <highgui.h>
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ Code

.. code-block:: cpp
#include <cv.h>
#include <highgui.h>
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
Expand Down
48 changes: 23 additions & 25 deletions doc/tutorials/highgui/trackbar/trackbar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ Let's modify the program made in the tutorial :ref:`Adding_Images`. We will let

.. code-block:: cpp
#include <cv.h>
#include <highgui.h>
#include <opencv2/opencv.hpp>
using namespace cv;
/// Global Variables
Expand All @@ -50,41 +48,41 @@ Let's modify the program made in the tutorial :ref:`Adding_Images`. We will let
*/
void on_trackbar( int, void* )
{
alpha = (double) alpha_slider/alpha_slider_max ;
beta = ( 1.0 - alpha );
alpha = (double) alpha_slider/alpha_slider_max ;
beta = ( 1.0 - alpha );
addWeighted( src1, alpha, src2, beta, 0.0, dst);
addWeighted( src1, alpha, src2, beta, 0.0, dst);
imshow( "Linear Blend", dst );
imshow( "Linear Blend", dst );
}
int main( int argc, char** argv )
{
/// Read image ( same size, same type )
src1 = imread("../../images/LinuxLogo.jpg");
src2 = imread("../../images/WindowsLogo.jpg");
/// Read image ( same size, same type )
src1 = imread("../../images/LinuxLogo.jpg");
src2 = imread("../../images/WindowsLogo.jpg");
if( !src1.data ) { printf("Error loading src1 \n"); return -1; }
if( !src2.data ) { printf("Error loading src2 \n"); return -1; }
if( !src1.data ) { printf("Error loading src1 \n"); return -1; }
if( !src2.data ) { printf("Error loading src2 \n"); return -1; }
/// Initialize values
alpha_slider = 0;
/// Initialize values
alpha_slider = 0;
/// Create Windows
namedWindow("Linear Blend", 1);
/// Create Windows
namedWindow("Linear Blend", 1);
/// Create Trackbars
char TrackbarName[50];
sprintf( TrackbarName, "Alpha x %d", alpha_slider_max );
/// Create Trackbars
char TrackbarName[50];
sprintf( TrackbarName, "Alpha x %d", alpha_slider_max );
createTrackbar( TrackbarName, "Linear Blend", &alpha_slider, alpha_slider_max, on_trackbar );
createTrackbar( TrackbarName, "Linear Blend", &alpha_slider, alpha_slider_max, on_trackbar );
/// Show some stuff
on_trackbar( alpha_slider, 0 );
/// Show some stuff
on_trackbar( alpha_slider, 0 );
/// Wait until user press some key
waitKey(0);
return 0;
/// Wait until user press some key
waitKey(0);
return 0;
}
Expand Down
26 changes: 9 additions & 17 deletions doc/tutorials/introduction/linux_eclipse/linux_eclipse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ Making a project

.. code-block:: cpp
#include <cv.h>
#include <highgui.h>
#include <opencv2/opencv.hpp>
using namespace cv;
Expand All @@ -81,7 +80,7 @@ Making a project
return -1;
}
namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
namedWindow( "Display Image", WINDOW_AUTOSIZE );
imshow( "Display Image", image );
waitKey(0);
Expand Down Expand Up @@ -206,22 +205,15 @@ Say you have or create a new file, *helloworld.cpp* in a directory called *foo*:
.. code-block:: cpp
#include <cv.h>
#include <highgui.h>
#include <opencv2/opencv.hpp>
using namespace cv;
int main ( int argc, char **argv )
{
cvNamedWindow( "My Window", 1 );
IplImage *img = cvCreateImage( cvSize( 640, 480 ), IPL_DEPTH_8U, 1 );
CvFont font;
double hScale = 1.0;
double vScale = 1.0;
int lineWidth = 1;
cvInitFont( &font, CV_FONT_HERSHEY_SIMPLEX | CV_FONT_ITALIC,
hScale, vScale, 0, lineWidth );
cvPutText( img, "Hello World!", cvPoint( 200, 400 ), &font,
cvScalar( 255, 255, 0 ) );
cvShowImage( "My Window", img );
cvWaitKey();
Mat img(480, 640, CV_8U);
putText(img, "Hello World!", Point( 200, 400 ), FONT_HERSHEY_SIMPLEX | FONT_ITALIC, 1.0, Scalar( 255, 255, 0 ));
imshow("My Window", img);
waitKey();
return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ Here it is:
.. code-block:: cpp
:linenos:
#include <cv.h>
#include <highgui.h>
#include <opencv2/opencv.hpp>
using namespace cv;
Expand All @@ -45,12 +44,12 @@ Here it is:
}
Mat gray_image;
cvtColor( image, gray_image, CV_BGR2GRAY );
cvtColor( image, gray_image, COLOR_BGR2GRAY );
imwrite( "../../images/Gray_Image.jpg", gray_image );
namedWindow( imageName, CV_WINDOW_AUTOSIZE );
namedWindow( "Gray image", CV_WINDOW_AUTOSIZE );
namedWindow( imageName, WINDOW_AUTOSIZE );
namedWindow( "Gray image", WINDOW_AUTOSIZE );
imshow( imageName, image );
imshow( "Gray image", gray_image );
Expand Down
3 changes: 1 addition & 2 deletions include/opencv2/opencv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,14 @@
#define __OPENCV_ALL_HPP__

#include "opencv2/core.hpp"
#include "opencv2/flann/miniflann.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/photo.hpp"
#include "opencv2/video.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/objdetect.hpp"
#include "opencv2/calib3d.hpp"
#include "opencv2/ml.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/contrib.hpp"
#include "opencv2/ml.hpp"

#endif
9 changes: 5 additions & 4 deletions modules/core/doc/drawing_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,11 @@ The function draws contour outlines in the image if
:math:`\texttt{thickness} \ge 0` or fills the area bounded by the contours if
:math:`\texttt{thickness}<0` . The example below shows how to retrieve connected components from the binary image and label them: ::

#include "cv.h"
#include "highgui.h"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"

using namespace cv;
using namespace std;

int main( int argc, char** argv )
{
Expand All @@ -530,15 +531,15 @@ The function draws contour outlines in the image if
vector<Vec4i> hierarchy;

findContours( src, contours, hierarchy,
CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE );
RETR_CCOMP, CHAIN_APPROX_SIMPLE );

// iterate through all the top-level contours,
// draw each connected component with its own random color
int idx = 0;
for( ; idx >= 0; idx = hierarchy[idx][0] )
{
Scalar color( rand()&255, rand()&255, rand()&255 );
drawContours( dst, contours, idx, color, CV_FILLED, 8, hierarchy );
drawContours( dst, contours, idx, color, FILLED, 8, hierarchy );
}

namedWindow( "Components", 1 );
Expand Down
6 changes: 3 additions & 3 deletions modules/core/doc/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ OpenCV deallocates the memory automatically, as well as automatically allocates

Example: ::

#include "cv.h"
#include "highgui.h"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"

using namespace cv;

Expand All @@ -119,7 +119,7 @@ Example: ::
for(;;)
{
cap >> frame;
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);
imshow("edges", edges);
Expand Down
1 change: 0 additions & 1 deletion modules/gpu/app/nv_perf_test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <opencv2/gpu.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/video.hpp>
#include <opencv2/legacy.hpp>
#include <opencv2/ts.hpp>

static void printOsInfo()
Expand Down
6 changes: 4 additions & 2 deletions modules/gpu/perf/perf_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,9 @@ PERF_TEST_P(Sz_3Depth, Core_AddWeighted,
// GEMM

CV_FLAGS(GemmFlags, 0, cv::GEMM_1_T, cv::GEMM_2_T, cv::GEMM_3_T)
#define ALL_GEMM_FLAGS Values(0, CV_GEMM_A_T, CV_GEMM_B_T, CV_GEMM_C_T, CV_GEMM_A_T | CV_GEMM_B_T, CV_GEMM_A_T | CV_GEMM_C_T, CV_GEMM_A_T | CV_GEMM_B_T | CV_GEMM_C_T)
#define ALL_GEMM_FLAGS Values(0, (int)cv::GEMM_1_T, (int)cv::GEMM_2_T, (int)cv::GEMM_3_T, \
(int)cv::GEMM_1_T | cv::GEMM_2_T, (int)cv::GEMM_1_T | cv::GEMM_3_T, \
(int)cv::GEMM_1_T | cv::GEMM_2_T | cv::GEMM_3_T)

DEF_PARAM_TEST(Sz_Type_Flags, cv::Size, MatType, GemmFlags);

Expand Down Expand Up @@ -2071,7 +2073,7 @@ PERF_TEST_P(Sz_Depth, Core_CountNonZero,
//////////////////////////////////////////////////////////////////////
// Reduce

CV_ENUM(ReduceCode, CV_REDUCE_SUM, CV_REDUCE_AVG, CV_REDUCE_MAX, CV_REDUCE_MIN)
CV_ENUM(ReduceCode, cv::REDUCE_SUM, cv::REDUCE_AVG, cv::REDUCE_MAX, cv::REDUCE_MIN)
#define ALL_REDUCE_CODES ValuesIn(ReduceCode::all())

enum {Rows = 0, Cols = 1};
Expand Down
4 changes: 2 additions & 2 deletions modules/gpu/perf/perf_imgproc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1794,7 +1794,7 @@ PERF_TEST_P(Sz_Dp_MinDist, ImgProc_HoughCircles,
cv::gpu::GpuMat d_circles;
cv::gpu::HoughCirclesBuf d_buf;

TEST_CYCLE() cv::gpu::HoughCircles(d_src, d_circles, d_buf, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);
TEST_CYCLE() cv::gpu::HoughCircles(d_src, d_circles, d_buf, cv::HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);

cv::Mat gpu_circles(d_circles);
cv::Vec3f* begin = gpu_circles.ptr<cv::Vec3f>(0);
Expand All @@ -1806,7 +1806,7 @@ PERF_TEST_P(Sz_Dp_MinDist, ImgProc_HoughCircles,
{
std::vector<cv::Vec3f> cpu_circles;

TEST_CYCLE() cv::HoughCircles(src, cpu_circles, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);
TEST_CYCLE() cv::HoughCircles(src, cpu_circles, cv::HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);

SANITY_CHECK(cpu_circles);
}
Expand Down
1 change: 0 additions & 1 deletion modules/gpu/perf/perf_precomp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
#include "opencv2/calib3d.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/video.hpp"
#include "opencv2/legacy.hpp"
#include "opencv2/photo.hpp"

#include "opencv2/core/gpu_private.hpp"
Expand Down
1 change: 1 addition & 0 deletions modules/gpu/perf/perf_video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
//M*/

#include "perf_precomp.hpp"
#include "opencv2/legacy.hpp"

using namespace std;
using namespace testing;
Expand Down
1 change: 0 additions & 1 deletion modules/gpu/perf4au/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
#include "opencv2/gpu.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/video.hpp"
#include "opencv2/legacy.hpp"
#include "opencv2/ts.hpp"
#include "opencv2/ts/gpu_perf.hpp"

Expand Down
1 change: 0 additions & 1 deletion modules/gpu/test/test_precomp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
#include "opencv2/ts.hpp"
#include "opencv2/ts/gpu_test.hpp"
#include "opencv2/gpu.hpp"
#include "opencv2/legacy.hpp"

#include "interpolation.hpp"
#include "main_test_nvidia.h"
Expand Down
15 changes: 7 additions & 8 deletions modules/imgproc/doc/feature_detection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ The function finds circles in a grayscale image using a modification of the Houg

Example: ::

#include <cv.h>
#include <highgui.h>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <math.h>

using namespace cv;
Expand All @@ -317,11 +317,11 @@ Example: ::
Mat img, gray;
if( argc != 2 && !(img=imread(argv[1], 1)).data)
return -1;
cvtColor(img, gray, CV_BGR2GRAY);
cvtColor(img, gray, COLOR_BGR2GRAY);
// smooth it, otherwise a lot of false circles may be detected
GaussianBlur( gray, gray, Size(9, 9), 2, 2 );
vector<Vec3f> circles;
HoughCircles(gray, circles, CV_HOUGH_GRADIENT,
HoughCircles(gray, circles, HOUGH_GRADIENT,
2, gray->rows/4, 200, 100 );
for( size_t i = 0; i < circles.size(); i++ )
{
Expand Down Expand Up @@ -426,9 +426,8 @@ The function implements the probabilistic Hough transform algorithm for line det
/* This is a standalone program. Pass an image name as the first parameter
of the program. Switch between standard and probabilistic Hough transform
by changing "#if 1" to "#if 0" and back */
#include <cv.h>
#include <highgui.h>
#include <math.h>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>

using namespace cv;

Expand All @@ -439,7 +438,7 @@ The function implements the probabilistic Hough transform algorithm for line det
return -1;

Canny( src, dst, 50, 200, 3 );
cvtColor( dst, color_dst, CV_GRAY2BGR );
cvtColor( dst, color_dst, COLOR_GRAY2BGR );

#if 0
vector<Vec2f> lines;
Expand Down
6 changes: 3 additions & 3 deletions modules/imgproc/doc/histograms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ arrays. The elements of a tuple used to increment
a histogram bin are taken from the corresponding
input arrays at the same location. The sample below shows how to compute a 2D Hue-Saturation histogram for a color image. ::

#include <cv.h>
#include <highgui.h>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>

using namespace cv;

Expand All @@ -53,7 +53,7 @@ input arrays at the same location. The sample below shows how to compute a 2D Hu
if( argc != 2 || !(src=imread(argv[1], 1)).data )
return -1;

cvtColor(src, hsv, CV_BGR2HSV);
cvtColor(src, hsv, COLOR_BGR2HSV);

// Quantize the hue to 30 levels
// and the saturation to 32 levels
Expand Down
1 change: 0 additions & 1 deletion modules/imgproc/include/opencv2/imgproc/imgproc_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#ifndef __OPENCV_IMGPROC_IMGPROC_C_H__
#define __OPENCV_IMGPROC_IMGPROC_C_H__

#include "opencv2/core/core_c.h"
#include "opencv2/imgproc/types_c.h"

#ifdef __cplusplus
Expand Down
Loading

0 comments on commit 8f32902

Please sign in to comment.