YouTip LogoYouTip

Opencv Basic

OpenCV is a powerful computer vision library with multiple modules, each focusing on different functionalities. OpenCV is composed of multiple modules, each providing different functionalities. The following are some of the most commonly used modules in OpenCV: * **cv2.core**: Core module, containing basic image processing functionalities (such as representation and manipulation of image arrays). * **cv2.imgproc**: Image processing module, providing various image operations such as filtering, image transformation, morphological operations, etc. * **cv2.highgui**: Graphical user interface module, providing functionality for displaying images and videos. * **cv2.video**: Provides video processing functionalities such as video capture, video stream processing, etc. * **cv2.features2d**: Feature detection and matching module, containing corner, edge, keypoint detection, etc. * **cv2.ml**: Machine learning module, providing various machine learning algorithms for image classification, regression, clustering, etc. * **cv2.calib3d**: Camera calibration and 3D reconstruction module. * **cv2.objdetect**: Object detection module. * **cv2.dnn**: Deep learning module. ### **1. Core Module** **Functionality:** Provides core OpenCV functionalities, including basic data structures, matrix operations, drawing functions, etc. **Main Classes and Functions:** * **Mat:** The basic data structure in OpenCV for storing images and matrices. * **Scalar:** Used to represent colors or pixel values. * **Point、Size、Rect:** Used to represent points, sizes, and rectangles. * **Basic Drawing Functions:** `cv.line()`, `cv.circle()`, `cv.rectangle()`, `cv.putText()`, etc. **Application Scenarios:** * Basic image operations (such as creation, copying, cropping). * Drawing geometric shapes and text. * * * ### **2. Imgproc Module** **Functionality:** Provides image processing functionalities including image filtering, geometric transformations, color space conversion, etc. **Main Classes and Functions:** * **Image Filtering:** `cv.blur()`, `cv.GaussianBlur()`, `cv.medianBlur()`, etc. * **Geometric Transformations:** `cv.resize()`, `cv.warpAffine()`, `cv.warpPerspective()`, etc. * **Color Space Conversion:** `cv.cvtColor()` (such as BGR to grayscale, BGR to HSV). * **Threshold Processing:** `cv.threshold()`, `cv.adaptiveThreshold()`. * **Edge Detection:** `cv.Canny()`, `cv.Sobel()`, `cv.Laplacian()`. **Application Scenarios:** * Image smoothing, sharpening, edge detection. * Image scaling, rotation, affine transformation. * Image binarization, color space conversion. * * * ### **3. HighGUI Module** **Functionality:** Provides high-level GUI and media I/O functionalities for image display and interaction. **Main Classes and Functions:** * **Image Display:** `cv.imshow()`, `cv.waitKey()`, `cv.destroyAllWindows()`. * **Video Capture:** `cv.VideoCapture()`, `cv.VideoWriter()`. * **Mouse and Keyboard Events:** `cv.setMouseCallback()`. **Application Scenarios:** * Displaying images and videos. * Capturing from camera or video files. * Handling user interactions (such as mouse clicks, keyboard input). * * * ### **4. Video Module** **Functionality:** Provides video analysis functionalities including motion detection, object tracking, etc. **Main Classes and Functions:** * **Background Subtraction:** `cv.createBackgroundSubtractorMOG2()`, `cv.createBackgroundSubtractorKNN()`. * **Optical Flow:** `cv.calcOpticalFlowPyrLK()`. * **Object Tracking:** `cv.TrackerKCF_create()`, `cv.TrackerMOSSE_create()`. **Application Scenarios:** * Motion detection in videos. * Object tracking (such as pedestrian, vehicle tracking). * * * ### **5. Calib3d Module** **Functionality:** Provides camera calibration and 3D reconstruction functionalities. **Main Classes and Functions:** * **Camera Calibration:** `cv.calibrateCamera()`, `cv.findChessboardCorners()`. * **3D Reconstruction:** `cv.solvePnP()`, `cv.reprojectImageTo3D()`. **Application Scenarios:** * Camera calibration (used for removing lens distortion). * 3D reconstruction (such as recovering 3D information from 2D images). * * * ### **6. Features2d Module** **Functionality:** Provides feature detection and description functionalities. **Main Classes and Functions:** * **Feature Detection:** `cv.SIFT_create()`, `cv.ORB_create()`, `cv.SURF_create()`. * **Feature Matching:** `cv.BFMatcher()`, `cv.FlannBasedMatcher()`. * **Keypoint Drawing:** `cv.drawKeypoints()`. **Application Scenarios:** * Image feature extraction and matching. * Image stitching, object recognition.
← Opencv Image OperatorOpencv First Example β†’