Ask Your Question
0

Convert Mat to normalized float array

asked 2018-01-31 12:21:15 -0600

Hello, I am trying to use opencv on android to detect objects and then to pass these objects to trained tensorflow model. The problem is that my tensorflow model needs float array of the image on the input and I cant give him Mat. Also the array should contains only values between 0 and 1. Is there any way to convert Mat to normalized float array?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-01-31 14:13:36 -0600

LBerger gravatar image

updated 2018-01-31 15:26:33 -0600

About Mat to normalized float array, you can use first use convertto and second use normalize

then you can use :

  vector<double> vec;
  Mat v = (Mat_<double>(1,6) << 0, 1.1, 2, 10, 11, 12);
  v.copyTo(vec);
  for (auto i : vec)
      cout << i << "\t";
   cout << " <- vec : vector<double>\n";
edit flag offensive delete link more

Comments

If I use convertto the output is Mat type not float or double. I need array that looks like numpy in python.

chepEtovaNeshto gravatar imagechepEtovaNeshto ( 2018-01-31 14:47:33 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-01-31 12:21:15 -0600

Seen: 1,675 times

Last updated: Jan 31 '18