# Detectnet - object in frames

**URL:** <https://forums.developer.nvidia.com/t/detectnet-object-in-frames/170726>\
**Category:** Jetson Nano\
**Tags:** jetson-inference\
**Created:** [March 11, 2021, 8:36pm UTC](https://forums.developer.nvidia.com/t/detectnet-object-in-frames/170726 "2021-03-11T20:36:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nerk](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@nerk](https://forums.developer.nvidia.com/u/nerk)\
**Post date:** [March 11, 2021, 8:36pm UTC](https://forums.developer.nvidia.com/t/detectnet-object-in-frames/170726/1 "2021-03-11T20:36:41Z")

</div>

Hello,  
As my adventure with imageAi fail with not enough fps, I started with jetson.inference.  
How can I reach result as on this picture: ![obraz](https://global.discourse-cdn.com/nvidia/original/3X/3/b/3b06e0a70e4c726f6bfa0396ec5e24cfdf184cc7.jpeg)

Code i pretty simple:

> import jetson.inference  
> import jetson.utils
> 
> net = jetson.inference.detectNet(threshold=0.5)  
> camera = jetson.utils.videoSource(“csi://0”)  
> display = jetson.utils.videoOutput(“display://0”)
> 
> while display.IsStreaming():  
> img = camera.Capture()  
> detections = net.Detect(img)  
> display.Render(img)  
> display.SetStatus(“Object Detection | Network {:.0f} FPS”.format(net.GetNetworkFPS()))

---

<div class="post-metadata">

**Author:** ![dusty\_nv](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/dusty_nv/32/14043_2.png) [@dusty\_nv](https://forums.developer.nvidia.com/u/dusty_nv)\
**Post date:** [March 11, 2021, 10:50pm UTC](https://forums.developer.nvidia.com/t/detectnet-object-in-frames/170726/2 "2021-03-11T22:50:29Z")

</div>

Hi @nerk, that image is not from jetson-inference, so you would need to [re-train the detection network](https://github.com/dusty-nv/jetson-inference/blob/master/docs/pytorch-ssd.md) on a dataset of construction equipment from aerial perspective.

Regarding the performance, the default detection model in jetson-inference (ssd-mobilenet-v2) was trained on the 90-class MS COCO dataset, so the model has a lot of classes. And the detection performance scales with the number of classes. So if you were to train your own model with fewer classes, it would speed it up.

Alternatively, you can look to DeepStream and training the models with Transfer Learning Toolkit for more optimized performance.

---

<div class="post-metadata">

**Author:** ![nerk](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@nerk](https://forums.developer.nvidia.com/u/nerk)\
**Post date:** [March 11, 2021, 11:33pm UTC](https://forums.developer.nvidia.com/t/detectnet-object-in-frames/170726/3 "2021-03-11T23:33:17Z")

</div>

I explained incorrect, my mistake.  
I would add bounding boxes, and avoid color mask on picture:  
If you can fallow me to right path I will be grateful.

I tried do something like this:

> import jetson.inference  
> import jetson.utils  
> import cv2  
> import numpy as np
> 
> net = jetson.inference.detectNet(argv=[“–output-bbox=boxes”,“–alpha=0”, “batch=5”],threshold=0.5)  
> camera = jetson.utils.videoSource(“csi://0”)  
> display = jetson.utils.videoOutput(“display://0”)
> 
> while display.IsStreaming():
> 
> img = camera.Capture()  
> image = img  
> detections = net.Detect(img)  
> cv\_img = jetson.utils.cudaToNumpy(img)  
> for detection in detections:  
> x = detection.Left  
> y = detection.Right  
> w = detection.Bottom  
> h = detection.Top
> 
> ```
> cv2.rectangle(cv_img, (x, h), (y, w), (0, 0, 255), 2)
> 
> ```
> 
> bgr\_img = jetson.utils.cudaFromNumpy(cv\_img, isBGR=True)  
> print(“x,y,w,h:”,x,y,w,h)  
> display.Render(bgr\_img)  
> display.SetStatus(“Object Detection | Network {:.0f} FPS”.format(net.GetNetworkFPS()))

---

<div class="post-metadata">

**Author:** ![dusty\_nv](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/dusty_nv/32/14043_2.png) [@dusty\_nv](https://forums.developer.nvidia.com/u/dusty_nv)\
**Post date:** [March 12, 2021, 3:43pm UTC](https://forums.developer.nvidia.com/t/detectnet-object-in-frames/170726/4 "2021-03-12T15:43:26Z")

</div>

> [@nerk](#):
>
> I would add bounding boxes, and avoid color mask on picture:

OK gotcha - call `net.Detect()` with the `overlay='none'` argument, then detectNet will skip overlaying the bounding boxes, allowing you to do it in OpenCV.

Also, `cudaToNumpy()` maps the memory into numpy (instead of copying it), so changes that are made it in OpenCV should show up in the original memory. I believe that should allow you to skip the `cudaFromNumpy()` part after.

---

<div class="post-metadata">

**Author:** ![nadeemm](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/nadeemm/32/367020_2.png) [@nadeemm](https://forums.developer.nvidia.com/u/nadeemm)\
**Post date:** [October 15, 2021, 4:58am UTC](https://forums.developer.nvidia.com/t/detectnet-object-in-frames/170726/5 "2021-10-15T04:58:04Z")

</div>

Closed on October 15, 2021, 4:58am UTC


