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

Displaying stitched images together without cutoff using warpAffine

July 12 Edit: This post inspired GitHub repos providing functions to accomplish this task; one for a padded warpAffine() and another for a padded warpPerspective(). Check out the Python version or the C++ version. Transformations shift the location of pixels What any transformation does is takes your point coordinates (x, y) and maps them to … Read more

Configuring an c++ OpenCV project with Cmake

First: create a folder Project containing two subfolders src and include, and a file called CMakeLists.txt. Second: Put your cpp inside the src folder and your headers in the include folders. Third: Your CMakeLists.txt should look like this: cmake_minimum_required(VERSION 2.8) PROJECT (name) find_package(OpenCV REQUIRED ) set( NAME_SRC src/main.cpp ) set( NAME_HEADERS include/header.h ) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/include … Read more

How to capture the desktop in OpenCV (ie. turn a bitmap into a Mat)?

After MUCH trial and error, I managed to write a function to do it. here it is for anyone else who might want it: #include “stdafx.h” #include “opencv2/core/core.hpp” #include “opencv2/imgproc/imgproc.hpp” #include <opencv2/highgui/highgui.hpp> #include <Windows.h> #include <iostream> #include <string> using namespace std; using namespace cv; Mat hwnd2mat(HWND hwnd){ HDC hwindowDC,hwindowCompatibleDC; int height,width,srcheight,srcwidth; HBITMAP hbwindow; Mat src; … Read more

Computing x,y coordinate (3D) from image point

Given your configuration, errors of 20-40mm at the edges are average. It looks like you’ve done everything well. Without modifying camera/system configuration, doing better will be hard. You can try to redo camera calibration and hope for better results, but this will not improve them alot (and you may eventually get worse results, so don’t … Read more

How to define the markers for Watershed in OpenCV?

First of all: the function minMaxLoc finds only the global minimum and global maximum for a given input, so it is mostly useless for determining regional minima and/or regional maxima. But your idea is right, extracting markers based on regional minima/maxima for performing a Watershed Transform based on markers is totally fine. Let me try … Read more

How to detect simple geometric shapes using OpenCV

If you have only these regular shapes, there is a simple procedure as follows : Find Contours in the image ( image should be binary as given in your question) Approximate each contour using approxPolyDP function. First, check number of elements in the approximated contours of all the shapes. It is to recognize the shape. … Read more