Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are opencv's Mat::rows and Mat::cols signed instead of unsigned?

Tags:

c++

opencv

I'm compiling a program with gcc's -Wall flag. I do a comparison (with an unsigned int) on Mat::cols and Mat::rows at some point and get a warning about comparing signed and unsigned ints. Although it's not a big deal to cast this away, I'm curious as to what the rationale behind a Mat that has a negative size is.

Logically, a matrix can't be any emptier than an empty matrix (with 0 rows and 0 cols), so what would a matrix with -1 rows or -1 cols mean?

There doesn't seem to be much performance difference between computations on signed and unsigned ints either.

like image 237
Sveltely Avatar asked Mar 14 '14 02:03

Sveltely


1 Answers

i think because mostly int i is used as loop counter. with uint as cols and rows many warnings will appear. Also bulding differences of dimensions would be a bit more error prone.

beside that. in my opinions OpenCv is not a good example of good design at all. there are dozens of examples of bad class design. Also the design of the generated documentation is terrible (all overloads of a function and its parameters are mixed together for example).

But it is a very comprehensive and good image processing library. and that excuses a lot :)

like image 116
vlad_tepesch Avatar answered Sep 23 '22 15:09

vlad_tepesch