OpenCV: process every frame

According to the code below, all callbacks would have to follow this definition: IplImage* custom_callback(IplImage* frame); This signature means the callback is going to be executed on each frame retrieved by the system. On my example, make_it_gray() allocates a new image to save the result of the grayscale conversion and returns it. This means you … Read more

java.lang.UnsatisfiedLinkError: Native Library XXX.so already loaded in another classloader

The problem is with how OpenCV handles the initialization of the native library. Usually a class that uses a native library will have a static initializer that loads the library. This way the class and the native library will always be loaded in the same class loader. With OpenCV the application code loads the native … Read more

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

Convert a single color with cvtColor

Your second approach is correct, but you have source and destination of different types in cvtColor, and that causes the error. Be sure to have both hsv and bgr of the same type, CV_32F here: #include <opencv2/opencv.hpp> #include <iostream> int main() { cv::Mat3f hsv(cv::Vec3f(0.7, 0.7, 0.8)); std::cout << “HSV: ” << hsv << std::endl; cv::Mat3f … Read more

OpenCV: how to rotate IplImage?

If you use OpenCV > 2.0 it is as easy as using namespace cv; Mat rotateImage(const Mat& source, double angle) { Point2f src_center(source.cols/2.0F, source.rows/2.0F); Mat rot_mat = getRotationMatrix2D(src_center, angle, 1.0); Mat dst; warpAffine(source, dst, rot_mat, source.size()); return dst; } Note: angle is in degrees, not radians. See the C++ interface documentation for more details and … Read more