Hi,
I made a container where I installed OpenCV and loaded the VisionWorks folder,
I wanted to simply read a image and show it on Display Host using ovxio, here is the code:
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <memory>
#include <NVX/nvx.h>
#include <NVX/nvx_timer.hpp>
#include <NVX/Application.hpp>
#include <NVX/ConfigParser.hpp>
#include <OVX/FrameSourceOVX.hpp>
#include <OVX/RenderOVX.hpp>
#include <NVX/SyncTimer.hpp>
#include <OVX/UtilityOVX.hpp>
#include "NVX/nvx_opencv_interop.hpp"
#include <opencv2/core/mat.hpp>
#include <opencv2/imgcodecs.hpp>
#include "opencv2/imgproc.hpp"
#include "opencv2/videoio.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/calib3d.hpp"
static void VX_CALLBACK logCallback(vx_context context, vx_reference ref, vx_status status, const vx_char message[])
{
printf("[NVX LOG] context=" VX_FMT_REF ",ref=" VX_FMT_REF ",status=%d : %s \n", context, ref, status, message);
fflush(stdout);
}
int main(int argc, char* argv[])
{
ovxio::ContextGuard context;
vxDirective(context, VX_DIRECTIVE_ENABLE_PERFORMANCE);
vxRegisterLogCallback(context, logCallback,vx_false_e);
std::unique_ptr<ovxio::Render> renderer(ovxio::createDefaultRender(context,"Stereo Matching ", (vx_uint32)2560/2, (vx_uint32)1440));
if (!renderer)
{
std::cerr << "Error: Can't create a renderer" << std::endl;
return nvxio::Application::APP_EXIT_CODE_NO_RENDER;
}
cv::Mat frame_left = cv::imread("imgLeft.png",cv::IMREAD_COLOR);
vx_image gray_left = nvx_cv::createVXImageFromCVMat(context, frame_left);
while(true){
renderer->putImage(gray_left);
renderer->flush();
}
}
command launch container:
xhost +si:localuser:root docker run --network host -it --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix sa/vision-light:1.0
error:
Error: Can’t create a renderer
by removing the if control the error is:
Segmentation fault (core dumped)
if I use OpenCV with imshow from the container I can get the image on the host
Thanks