I have a c++ facerecognition code and a python code in opencv. In python code i read frames from a robot and i want to send this fram to my c++ code. I use this link tho call p
Since showNaoImage
returns a numpy array, you can use numpy's C API to extract values from the frame, or obtain the pointer to the memory that holds the values. See the documentation, specifically the part that deals with array data access.
To convert the data to a Mat
array accepted by cv::imshow
, use the Mat
constructor with the data and its dimensions. For example:
// numpy array created from a PIL image is 3-dimensional:
// height x width x num_channels (num_channels being 3 for RGB)
assert (PyArray_NDIM(presult) == 3 && PyArray_SHAPE(presult)[2] == 3);
// Extract the metainformation and the data.
int rows = PyArray_SHAPE(presult)[0];
int cols = PyArray_SHAPE(presult)[1];
void *frame_data = PyArray_DATA(presult);
// Construct the Mat object and use it.
Mat cv_frame(rows, cols, CV_8UC3, frame_data);
cv::imshow("Original_image", cv_frame);