Im trying to translate my Python code to C++ (for speed up).
My code receive the image by socket and just show it.
Python code:
self._img = cv2.imdecode(np.fromstring(self._SocketData, np.uint8), 1)
if not self._img is None:
self._img = cv2.resize(self._img, (1280, 720))
cv2.imshow("1", self._img)
cv2.waitKey(1)
Unfortunately, i get problem with "np.fromstring" in C++.
How to implement that?
Im trying this:
while (ignored_error != boost::asio::error::eof) {
boost::array<uchar, 10000> RECV_DATA;
size_t ImageSize = image_recver.read_some(
boost::asio::buffer(RECV_DATA), ignored_error);
vector<uchar> Img (ImageSize);
for (int i = 0; i < ImageSize; i++) {
Img[i] = RECV_DATA[i];
}
Mat img(1280, 720, CV_64F, Img.data());
imshow("1", img);
waitKey(1);
}
But this is not working (I think this is due with "cv2.imdecode" and "np.fromstring").
Please, help me
P.S Generally, my main problem exactly in np.fromstring, because from socket im get a string, not a some bytes or integers and i should transform a string to array of pixels from (0-255 each)