简体   繁体   中英

Compare Area of two matrices Opencv

Let, cv::Mat matrix_1 and cv:Mat matrix_2 be two matrices. How can we compare these two matrices?

  • matrix_1 < matrix_2
  • matrix_1 >= matrix_2

I used the following approach:

 if((matrix_1.rows < matrix_2.rows) && (matrix_1.cols < matrix_2.cols)) then matrix_1 < matrix_2

Reason for asking the question

I am using a query image in order to find the closest match in a database. and I want the size of the query Image which is matrix_1 to be less than the size of all the other images in the database.

Link: Tutorial matching

so, if you only want to compare the area:

Mat A = ...
Mat B = ...

int areaA = (A.rows*A.cols);
int areaB = (B.rows*B.cols);

bool a_is_smaller = areaA < areaB;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM