OpenCV Python cv2.perspectiveTransform

This implementation really needs to be changed in a future version. From the OpenCV docs for perspectiveTransform(): src – input two-channel (…) floating-point array Slant emphasis added by me. So we see from here that A is just a single-channel matrix, that is, two-dimensional. One row, two cols. You instead need a two-channel image, i.e., a three-dimensional matrix where the length of the … Read more

Why do we convert from RGB to HSV

According to http://en.wikipedia.org/wiki/HSL_and_HSV#Use_in_image_analysis : Because the R, G, and B components of an object’s color in a digital image are all correlated with the amount of light hitting the object, and therefore with each other, image descriptions in terms of those components make object discrimination difficult. Descriptions in terms of hue/lightness/chroma or hue/lightness/saturation are often more relevant. … 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. For eg, … Read more

Python: Can’t convert float NaN to integer

Based on what you have posted, your movingAverage() function is returning NaN at some point. NaN is a special floating point sentinel value, meaning “Not a Number.” In general, Python prefers raising an exception to returning NaN, so things like sqrt(-1) and log(0.0) will generally raise instead of returning NaN. However, you may get this value back from some other library. A good example might be … Read more