@KamalLAGH posted a new topic, subject "TensorFlow object detection API OpenCV inference returns wrong Box coordinaates prediction". It read:

   ##  Description
    
    Hi,  
    I am trying to use OpenCV instead of PIL to do inference with the generated TRT engine.  
    Following the link : TensorFlow Object Detection API Models in TensorRT, I correctly converted the TensorFlow 2 model and generated the TensorRT engine and tested with the infer script.  
    I am now trying to use the OpenCV library to be able to use the webcam to read and infer the images. However, I am getting false predictions of bounding box coordinates.  
    Could you please take a look at my code attached? any help is very appreciated.
    
    ##  Environment
    
    **TensorRT Version** : 8  
    **NVIDIA GPU** : Tegra Nvidia Jetson Nano & GeForce GTX 1070  
    **CUDA Version** : 11  
    **CUDNN Version** : 8  
    **Operating System** : Linux Ubuntu 18.04).06 LTS with Jetpack 4.6.1 && Windows 10  
    **Python Version (if applicable)** : 3  
    **Tensorflow Version (if applicable)** : 2.5  
    **OpenCV Version (if applicable)** : 4.6
    
    ##  Relevant Files
    
    Dropbox
    
    ### OpenCV_TensorRT_OD.rar
    
    Shared with Dropbox
    
    ##  Steps To Reproduce
    
    change image path line 162  
    Execute the code python test.py
    
    coco_classes.txt
    
    →

After which, @AastaLLL added

    Hi,
    
    Which JetPack version do you use?  
    More, do you get the correct output on a desktop environment?
    
    Thanks.

To which @KamalLAGH replied

    Hi @AastaLLL  
    I am using Jetpack 4.6.1. The same thing I got even on the desktop environment.  
    The first bounding box of the person in the left middle seems correct. However, the other object bounding box coordinates are not.  
    
    
    TensorRT_python1352×900 417 KB

Then @KamalLAGH said

    Hi @AastaLLL  
    I think I have found it. It is about pre-processing the image. I have to convert the format from NCHW to NHWC format.  
    ` blob = blob.transpose((0,2, 3, 1))`  
    I will upload the full code in GuitHub  
    
    
    TensorRT_python1352×900 408 KB

So @system (system) replied

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


{'source': 'discourse', 'url': 'https://forums.developer.nvidia.com/t/tensorflow-object-detection-api-opencv-inference-returns-wrong-box-coordinaates-prediction/222450', 'title': 'TensorFlow object detection API OpenCV inference returns wrong Box coordinaates prediction', 'views': 156, 'has_accepted_answer': True, 'word_count': 320, 'like_count': 0, 'reply_count': 1, 'participant_count': 2, 'posts': 5, 'tags': 'cuda tensorrt jetson-inference python tensorflow opencv ssd', 'author': '@KamalLAGH', 'participants': '@KamalLAGH, @AastaLLL, @system (system)', 'image_url': ['https://global.discourse-cdn.com/nvidia/original/3X/a/a/aad44fba97418cf5c1f7a6ee6f34af8e2b20ef73.png'], 'created_at': '2022-07-31T13:27:04.458Z', 'last_posted_at': '2022-08-24T02:27:54.301Z'}