I\'m developing a shape identification project using JavaCV and I have found some OpenCV code to identify U shapes in a particular image. I have tried to convert it into JavaCV
Check your type promotions, e.g.:
if (10 < (w/h) || (w/h) < 0.1){
.. is highly suspect. To get a floating point division, one (or both) of the operands must at least be a float
(and likewise a double
for double division). Otherwise, as in this case, it is an integer division. (Note that the original code has promotion to float
as well.)
For instance:
float ratio = (float)w/h; // (float / int) => (float / float) -> float
if (10 < ratio || ratio < 0.1 ) {
(Although I am unsure if this is the issue here.)
Happy coding!