samedi 21 mars 2020

OpenCV - How to avoid -nan values while working with large numbers?

I am trying to find the row average of a a 3 x N matrix using the cv::reduce() function.

My matrix cv::Mat points looks like below :

[1.181744771277993e+19, 1.981584126062363e+18, 1.066452623850629e+19, ....;
 1.239390846186213e+19, 3.63170321047822e+19,  8.358682062604993e+18, ....;
 1                    , 1                   ,  1                    , ....]

When I run the following lines of code for finding the row mean, I get all -nan values :

cv::Mat centroid; // Dimension 3 x 1
cv::reduce(points, centroid, 1, cv::REDUCE_AVG);

The final output of centroid is like this below :

[-nan;
 -nan;
  1]

I am not sure how I can avoid this situation? My centroid.type() is already CV_64FC1.

Aucun commentaire:

Enregistrer un commentaire