Hello everyone,
looking at the VisionWorks examples I couldn’t find anything that showed how to use an input taken from an IP camera and used in the VisionWorks graph.
Following the stereo_match example, I wrote my code but I had the problem that the image of the disparity I got was always calculated on the first frame, so the problem was the refresh of the vx_image image that I was using in the graph because I use OpenCV for the IP camera so it was not enough for me to read the new frame and assign it to the vx_image variables
I solved the problem this way and I wanted to ask you if it was the right way to do it and at the same time I shared the piece of code so anyone who has the same problem can try it.
.. //stuff .. right =vxCreateImageFromHandle(context,VX_DF_IMAGE_RGB,&right_addr,right_ptrs,VX_MEMORY_TYPE_HOST); left = vxCreateImageFromHandle(context, VX_DF_IMAGE_RGB, &left_addr, left_ptrs, VX_MEMORY_TYPE_HOST); .. //stuff .. std::unique_ptr<StereoMatching> stereo( StereoMatching::createStereoMatching( context, params, StereoMatching::HIGH_LEVEL_API, left, right, disparity)); while(true){ cap_left.read(frame_left); cap_right.read(frame_right); cv::cvtColor(frame_left, frame_left, cv::COLOR_BGR2RGB); cv::cvtColor(frame_right, frame_right, cv::COLOR_BGR2RGB); void *left_ptrs_new[] = { frame_left.data }; void *right_ptrs_new[] = { frame_right.data }; vxSwapImageHandle(left,left_ptrs_new,NULL,1); vxSwapImageHandle(right,right_ptrs_new,NULL,1); stereo->run(); .. //stuff ... }
I used vxSwapImageHandle to change the reference of the vx_image with the new frame taken from openCV, is it right or wrong how do I do it?
The output image now changes so it works, but looking at the documentation I could also use vxMapImagePatch ,vxUnmapImagePatch, vxCopyImagePatch, even using these other functions I have the same result, between these two methods which one do you recommend? or is it possible to acquire the frame directly from the IP camera in a vx_image?
Thanks in advance