Opencv doc reading notes - maxwillzq/opencvRead GitHub Wiki

https://en.wikipedia.org/wiki/OpenCV

Use open-source BSD license. launched in 1999 intel research. In 2012 august, non-profit foundation opencv.org take over opencv support.

http://docs.opencv.org/3.2.0/db/df5/tutorial_linux_gcc_cmake.html

\\sample codes
#include <opencv2/opencv.hpp>
using namespace cv;
Mat image;
image = imread(file,1);
namedWindow("window name", WINDOW_AUTOSIZE);
imshow("Display", image);
waitkey(0);

use cmake to build it

http://docs.opencv.org/3.2.0/d7/d16/tutorial_linux_eclipse.html

Qiang: how to output opencv linked lib path?

If you do not know where your opencv files are, open the Terminal and type: pkg-config --cflags opencv For instance, that command gave me this output: -I/usr/local/include/opencv -I/usr/local/include

http://docs.opencv.org/3.2.0/d4/db1/tutorial_documentation.html

This page show good example how to use latex in doxygen document.

http://docs.opencv.org/3.2.0/db/dfa/tutorial_transition_guide.html

describe how to transit from opencv 2.4 to 3.2

Good way to use cv:algorithm

// good ways
Ptr<SomeAlgo> algo = makePtr<SomeAlgo>(...);
Ptr<SomeAlgo> algo = SomeAlgo::create(...);

It also have a lot machine learning function in ml module. This is rewritten in 3.0 ocl (opencl) have been hide behind c++ interface

The Core Functionality (core module)

http://docs.opencv.org/3.2.0/d6/d6d/tutorial_mat_the_basic_image_container.html

Mat no need manage memory manually Use reference count for memory management, also assign and copy only copy header, not the pointer matrix. If users want to copy the matrix, use function clone() or copyTo()

http://docs.opencv.org/3.2.0/db/da5/tutorial_how_to_scan_images.html example code how to read and scan image https://github.com/opencv/opencv/blob/master/samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp We have 3 different ways: c style, iterator, and loop

here also show how to use stringstream to read string and output as int

int divideWith = 0; // convert our input string to number - C++ style
    stringstream s;
    s << argv[2];
    s >> divideWith;
#include <opencv2/core.hpp>
#include <opencv2/core/utility.hpp>
#include "opencv2/imgcodecs.hpp"

http://docs.opencv.org/3.2.0/d7/d37/tutorial_mat_mask_operations.html

The idea is that we recalculate each pixels value in an image according to a mask matrix (also known as kernel). From a mathematical point of view we make a weighted average, with our specified values. Applying such filters are so common in image processing that in OpenCV there exist a function that will take care of applying the mask: filter2D '''c++ Mat kernel = (Mat_(3,3) << 0, -1, 0, -1, 5, -1, 0, -1, 0); filter2D( src, dst1, src.depth(), kernel ); ''' This function is shorter, less verbose and, because there are some optimizations, it is usually faster than the hand-coded method

http://docs.opencv.org/3.2.0/d5/d98/tutorial_mat_operations.html

read grayscale image: Mat img = imread(filename, 0); write to filename: imwrite(filename, img); use imdecode and imencode to read and write image from/to memory rather than a file. Read information at (x,y): Scalar intensity = img.at(Point(x, y)); or img.at(y,x);

cvtColor(img, grey, COLOR_BGR2GRAY); //convert color image to grayscale

Change image type from 8UC1 to 32FC1: src.convertTo(dst, CV_32F);

very useful to see intermediate results of your algorithm during development process. OpenCV provides a convenient way of visualizing images. A 8U image can be shown using:

Mat img = imread("image.jpg");
namedWindow("image", WINDOW_AUTOSIZE);
imshow("image", img);
waitKey();

construct Mat from vector

vector<Point2f> points;
//... fill the array
Mat pointsMat = Mat(points);

http://docs.opencv.org/3.2.0/d5/dc4/tutorial_adding_images.html

#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include <iostream>
...
  addWeighted( src1, alpha, src2, beta, 0.0, dst);
   imshow( "Linear Blend", dst );
   waitKey(0);

http://docs.opencv.org/3.2.0/d3/dc1/tutorial_basic_linear_transform.html

for( int y = 0; y < image.rows; y++ ) {
        for( int x = 0; x < image.cols; x++ ) {
            for( int c = 0; c < 3; c++ ) {
                new_image.at<Vec3b>(y,x)[c] =
                saturate_cast<uchar>( alpha*( image.at<Vec3b>(y,x)[c] ) + beta );
            }
        }
    }

instead: image.convertTo(new_image, -1, alpha, beta);

saturate_cast is resemble the standard C++ cast operations, such as static_cast() and others. They perform an efficient and accurate conversion from one primitive type to another.

http://docs.opencv.org/3.2.0/d3/d96/tutorial_basic_geometric_drawing.html

Use cv::Point to define 2D points in an image. Use cv::Scalar and why it is useful Draw a line by using the OpenCV function cv::line Draw an ellipse by using the OpenCV function cv::ellipse Draw a rectangle by using the OpenCV function cv::rectangle Draw a circle by using the OpenCV function cv::circle Draw a filled polygon by using the OpenCV function cv::fillPoly

http://docs.opencv.org/3.2.0/df/d61/tutorial_random_generator_and_text.html

https://docs.opencv.org/3.3.1/d8/d01/tutorial_discrete_fourier_transform.html

Usage of functions such as: cv::copyMakeBorder() , cv::merge() , cv::dft() , cv::getOptimalDFTSize() , cv::log() and cv::normalize() .

http://docs.opencv.org/3.2.0/dd/d74/tutorial_file_input_output_with_xml_yml.html

File Input and Output using XML and YAML files. Usage of OpenCV data structures such as cv::FileStorage , cv::FileNode or cv::FileNodeIterator . add write and read function

impage processing module

http://docs.opencv.org/3.2.0/d7/da8/tutorial_table_of_content_imgproc.html

#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"

using namespace cv;

In this tutorial you will learn how to apply diverse linear filters to smooth images using OpenCV functions such as:

cv::blur cv::GaussianBlur cv::medianBlur cv::bilateralFilter

http://docs.opencv.org/3.2.0/db/d8e/tutorial_threshold.html

threshold( src_gray, dst, threshold_value, max_BINARY_value,threshold_type );

http://docs.opencv.org/3.2.0/d2/d2c/tutorial_sobel_derivatives.html


⚠️ **GitHub.com Fallback** ⚠️