Gradle android build for different processor architectures

As of Android Gradle Plugin version 13 you can now generate seperate APK’s using the new “split” mechanism. You can read about it here. The default file structure for placing your .so files is: src -main -jniLibs -armeabi -arm.so -armeabi-v7a -armv7.so -x86 -x86.so -mips -mips.so Note that the name of the .so file is unimportant … Read more

Tracking white color using python opencv

Let’s take a look at HSV color space: You need white, which is close to the center and rather high. Start with sensitivity = 15 lower_white = np.array([0,0,255-sensitivity]) upper_white = np.array([255,sensitivity,255]) and then adjust the threshold to your needs. You might also consider using HSL color space, which stands for Hue, Saturation, Lightness. Then you … Read more

How to fix the error “QObject::moveToThread:” in opencv in python?

I got same problem, it was from opencv-python version problem for me. My Linux machine’s environment is as following: $ cat /etc/lsb-release … DISTRIB_DESCRIPTION=”Ubuntu 18.04.5 LTS” $ date Tue Aug 11 11:43:16 KST 2020 $ python –version Python 3.7.8 $ pip list|grep Qt PyQt5 5.15.0 PyQt5-sip 12.8.0 $ pip list|grep opencv-python opencv-python 4.3.0.38 I downgraded … Read more

Differences of using “const cv::Mat &”, “cv::Mat &”, “cv::Mat” or “const cv::Mat” as function parameters?

It’s all because OpenCV uses Automatic Memory Management. OpenCV handles all the memory automatically. First of all, std::vector, Mat, and other data structures used by the functions and methods have destructors that deallocate the underlying memory buffers when needed. This means that the destructors do not always deallocate the buffers as in case of Mat. … Read more

find intersection point of two lines drawn using houghlines opencv

You don’t want to get the intersections of the parallel lines; only the intersections of the vertical lines with those of the horizontal lines. Also, since you have vertical lines, calculating the slope will likely result in exploding or inf slopes, so you shouldn’t use the y = mx+b equations. You need to do two … Read more

Remove spurious small islands of noise in an image – Python OpenCV

A lot of your questions stem from the fact that you’re not sure how morphological image processing works, but we can put your doubts to rest. You can interpret the structuring element as the “base shape” to compare to. 1 in the structuring element corresponds to a pixel that you want to look at in … Read more

module’ object has no attribute ‘drawMatches’ opencv python

I am late to the party as well, but I installed OpenCV 2.4.9 for Mac OS X, and the drawMatches function doesn’t exist in my distribution. I’ve also tried the second approach with find_obj and that didn’t work for me either. With that, I decided to write my own implementation of it that mimics drawMatches … Read more

Python OpenCV convert image to byte string?

If you have an image img (which is a numpy array) you can convert it into string using: >>> img_str = cv2.imencode(‘.jpg’, img)[1].tostring() >>> type(img_str) ‘str’ Now you can easily store the image inside your database, and then recover it by using: >>> nparr = np.fromstring(STRING_FROM_DATABASE, np.uint8) >>> img = cv2.imdecode(nparr, cv2.CV_LOAD_IMAGE_COLOR) where you need … Read more

After install ROS Kinetic, cannot import OpenCV

It looks like this problem is caused by ROS adding /opt/ros/kinetic/lib/python2.7/dist-packages to the python path. This actually happens when you activate ROS with the command source /opt/ros/kinetic/setup.bash. This line is often added at the end of your bashrc file, in /home/username/.bashrc. A workaround is to remove this line from the bashrc file. This way the … Read more