OpenCV unable to set up SVM Parameters

A lot of things changed from OpenCV 2.4 to OpenCV 3.0. Among others, the machine learning module, which isn’t backward compatible. This is the OpenCV tutorial code for the SVM, update for OpenCV 3.0: #include <opencv2/core.hpp> #include <opencv2/imgproc.hpp> #include “opencv2/imgcodecs.hpp” #include <opencv2/highgui.hpp> #include <opencv2/ml.hpp> using namespace cv; using namespace cv::ml; int main(int, char**) { // … Read more

Removing black background and make transparent from grabcut output in python open cv

I have achieved this by using the following snippet. import cv2 file_name = “grab.png” src = cv2.imread(file_name, 1) tmp = cv2.cvtColor(src, cv2.COLOR_BGR2GRAY) _,alpha = cv2.threshold(tmp,0,255,cv2.THRESH_BINARY) b, g, r = cv2.split(src) rgba = [b,g,r, alpha] dst = cv2.merge(rgba,4) cv2.imwrite(“test.png”, dst)

OpenCV 3.0 LineIterator

I’ve solved my own problem. Line iterator seems to be unavailable in the cv2 library. Therefore, I made my own line iterator. No loops are used, so it should be pretty fast. Here is the code if anybody needs it: def createLineIterator(P1, P2, img): “”” Produces and array that consists of the coordinates and intensities … Read more

‘unresolved external symbol’ error when linking with OpenCV 3.0

Here the steps to use OpenCV 3.0.0 with precompiled libs, for a C++ project that links OpenCV statically, in Windows (tested with Windows 8.1) and Visual Studio (tested with Visual Studio 2013) to run this program: #include <opencv2\opencv.hpp> using namespace cv; int main() { Mat3b img = imread(“path_to_image”); imshow(“img”, img); waitKey(); return 0; } Download … Read more