Filling gaps in shape edges

Another, simpler way, that will probably translate better into OpenCV as it uses convolution rather than sequential Perl/C code. Basically set all the black pixels to value 10, and all the white pixels to value 0, then convolve the image with the following 3×3 kernel: 1 1 1 1 10 1 1 1 1 Now, … Read more

How to crop a CvMat in OpenCV?

OpenCV has region of interest functions which you may find useful. If you are using the cv::Mat then you could use something like the following. // You mention that you start with a CVMat* imagesource CVMat * imagesource; // Transform it into the C++ cv::Mat format cv::Mat image(imagesource); // Setup a rectangle to define your … Read more

How to use OpenCV SimpleBlobDetector

Python: Reads image blob.jpg and performs blob detection with different parameters. #!/usr/bin/python # Standard imports import cv2 import numpy as np; # Read image im = cv2.imread(“blob.jpg”) # Setup SimpleBlobDetector parameters. params = cv2.SimpleBlobDetector_Params() # Change thresholds params.minThreshold = 10 params.maxThreshold = 200 # Filter by Area. params.filterByArea = True params.minArea = 1500 # Filter … Read more

How to load png images with 4 channels?

If you are using OpenCV 2 or OpenCV 3 you should use IMREAD_* flags (as mentioned at here). C++ using namespace cv; Mat image = imread(“image.png”, IMREAD_UNCHANGED); Python import cv2 im = cv2.imread(“image.png”, cv2.IMREAD_UNCHANGED)

Why missing after opencv installed?

How to install opencv(cv2) with python bindings in Linux – Ubuntu/Fedora Install gcc, g++/gcc-c++, cmake (apt-get or yum, in case of yum use gcc-c++) apt-get install gcc, g++, cmake Downlaod latest opencv from openCV’s website Untar it with tar -xvf opencv-* Inside the untarred folder make a new folder called release mkdir release cd release … Read more

Sift implementation with OpenCV 2.2

Below is a minimal example: #include <opencv/cv.h> #include <opencv/highgui.h> int main(int argc, const char* argv[]) { const cv::Mat input = cv::imread(“input.jpg”, 0); //Load as grayscale cv::SiftFeatureDetector detector; std::vector<cv::KeyPoint> keypoints; detector.detect(input, keypoints); // Add results to image and save. cv::Mat output; cv::drawKeypoints(input, keypoints, output); cv::imwrite(“sift_result.jpg”, output); return 0; } Tested on OpenCV 2.3