Image comparison Deepstream vs opencv python

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) GPU
• DeepStream Version6.0.1
• JetPack Version (valid for Jetson only)
• TensorRT Version 8.2.3.1
• NVIDIA GPU Driver Version (valid for GPU only) 470.129.06
• Issue Type( questions, new requirements, bugs)

I ran a same image for a comparison in two ways

  1. Using following deepstream pipeline:
    GST_DEBUG=3 gst-launch-1.0 uridecodebin uri=file:///home/car.jpg ! m.sink_0 nvstreammux name=m batch-size=1 width=1920 height=1080 ! nvvideoconvert ! “video/x-raw(memory:NVMM), format=RGBA” ! dsexample full-frame=0 pre-process=1 ! …
    In dsexample, I read in_mat(input_image) in the pre-process function (in_mat is extracted from Gst_buffer using the reference implementation). As in_mat is in RGBA format I convert it into BGR and save it as ‘deepstream_image.jpg’

  2. In python, I do an cv2.imread of ‘car.jpg’ do a cv2 resize with (1920,1080) and save it as ‘python_image.jpg’

Ideally when I compare both the images (do image subtraction - img2 - img1), I should get a blank image but I get a different image (diff.jpg)

Request your help in resolving issue. Am I doing anything wrong? Where does the issue come up, deepstream or opencv? I shared the images for reference.




could your provide simple code to reproduce this issue? thanks.

For deepstream, this would be the code GST_DEBUG=3 gst-launch-1.0 uridecodebin uri=file:///home/car.jpg ! m.sink_0 nvstreammux name=m batch-size=1 width=1920 height=1080 ! nvvideoconvert ! “video/x-raw(memory:NVMM), format=RGBA” ! dsexample full-frame=0 pre-process=1 ! fakesink. In dsexample, in blur_objects function, we would add the following two lines at the start of the function

“cv::Mat new_mat;”
“cv::cvtColor(in_mat,new_mat,cv::COLOR_RGBA2BGR);”
“cv::imwrite(“deepstream_image.jpg”,new_mat);”

In python, the code could be:
“img = cv2.imread(‘car.jpg’)”
“cv2.resize(img,(1920,1080))”
"cv2.imwrite(“python_image.jpg”)

After both the images are generated, I would write a new python file with the following:
“img1 = cv2.imread(‘python_image.jpg’)”
“img2 = cv2.imread(‘deepstream_image.jpg’)”
“diff = img1 - img2”
“cv2.imshow(‘difference’,diff)”

  1. please check if they use the same resize method.
  2. To narrow down the issue, please compare the RGBA data.

Deepstream pipeline was resized using gstreamer. In python, I do a opencv resize but I don’t think they induce artifacts. Do you want to check RGBA (deepstream) vs RGB (python) ?

there are three steps to generate jpg files, that is jpeg decoding, raw data scale, jpeg encoding, maybe some step use different algorithm,please narrow down this issue by checking every step’s result.

I understood but finally they are in same color format and image difference should give a Zero but the difference is something else

please check step by step, check the decoding data is the same, check the data after scaling is the same.

There is no update from you for a period, assuming this is not an issue any more.
Hence we are closing this topic. If need further support, please open a new one.
Thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.