Welcome to Jetson Orin NX Developer Kit repository
当製品の日本語版マニュアル資料は、こちらからご取得ください。
04.Object embedding vector generation
Object embedding vector generation
Object embedding vector generation1. NVIDIA official application2. Case goal and processing chain2.1 People feature vector2.2 Retail product feature vector3. Startup entry and output4. Local video recognition4.1 Run4.2 Replace the local video4.3 Why the retail video preview plays slowly frame by frame while out.mp4 is smooth5. Real-time recognition with the USB camera5.1 Run5.2 About Retail6. Real-time recognition with the CSI camera6.1 Run7. Stopping, video output and troubleshooting
Applicable environment: JetPack 7.2.1, Ubuntu 24.04, DeepStream 9.1, Jetson Orin NX 16GB.
The factory environment already has the MDX application, the models, the TensorRT engines and the course entry. Start from section 4 for daily learning; refer to section 1 to deploy again only when the models, the engines or the program are damaged.
1. NVIDIA official application
This case uses the official NVIDIA DeepStream deepstream-mdx-perception-app, whose source code is located at:
text
~/deepstream_tao_apps/apps/tao_others/deepstream-mdx-perception-app
Official documentation: https://github.com/NVIDIA/DeepStream/tree/main/src/apps/tao_apps/apps/tao_others/deepstream-mdx-perception-app
The focus of MDX is not only the detection boxes, but the embedding (feature vector) attached to the targets. A feature vector is a sequence of numbers that can be used for later matching of same-class targets, retrieval of similar targets, cross-view association or database analysis.
The current course environment has already completed the application build, the model download and the engine build. Do not delete the .engine files under models/ casually; the engines are tied to the current Jetson, CUDA and TensorRT environment, and after the deletion the first run rebuilds them and takes a long time.
2. Case goal and processing chain
The course provides two MDX chains: one for people and one for retail products.
2.1 People feature vector
xxxxxxxxxxPeopleNet Transformer person detection↓NvDCF Tracker object tracking↓ReIdentificationNet↓Person embedding (256 dimensions)
The people mode is usually faster than the retail mode. The reason is that the people detection model is lighter, and the people targets in the frame are generally fewer than the product targets on the shelves.
2.2 Retail product feature vector
text
xxxxxxxxxxRetail DINO product detection↓NvDCF Tracker object tracking↓Retail Object Recognition↓Product category + embedding (448 dimensions)
The retail mode performs a second-level recognition on every detected product and extracts a feature vector. The input of Retail DINO is 960×540, which is clearly heavier than the people detection, so real-time camera scenarios need a dedicated low-latency strategy.
3. Startup entry and output
The current unified startup entry:
xxxxxxxxxx~/deepstream_tao_demo/run_mdx.sh video
| Input source | People mode | Retail mode |
|---|---|---|
| Local video | ~/deepstream_tao_demo/run_mdx.sh video | The Retail Object Recognition model is needed (it is not deployed in this environment) |
| USB camera | ~/deepstream_tao_demo/run_mdx.sh usb | The same, with the retail YAML |
| CSI camera | ~/deepstream_tao_demo/run_mdx.sh csi | The same, with the retail YAML |
All three entries display a window on the desktop of the Jetson device itself or on the VNC desktop. Parameter description:
-c: the YAML configuration file-m 2: the ReID pipeline (-m 3is the Retail one)--tiledtext: display the tiled text
4. Local video recognition
4.1 Run
xxxxxxxxxxcd ~/deepstream_tao_demoexport DISPLAY=:0./run_mdx.sh video

The video entry displays the detection results in real time and generates an out.mp4 with the detection boxes in the MDX application directory:
xxxxxxxxxx~/deepstream_tao_apps/apps/tao_others/deepstream-mdx-perception-app/out.mp4
After the run you can directly check whether the file is complete:
xxxxxxxxxxffprobe -v error -show_entries format=duration -of default=nw=1 \~/deepstream_tao_apps/apps/tao_others/deepstream-mdx-perception-app/out.mp4

4.2 Replace the local video
The people mode modification:
xxxxxxxxxx~/deepstream_tao_apps/configs/app/sources.csv
Change the video URI in the CSV to the absolute path on the Jetson:
xxxxxxxxxx1,3,file:///home/jetson/Videos/test.mp4,1,0,0
Using MP4/H.264 files is recommended. The Jetson path must be entered here; a Windows path must not be entered.
4.3 Why the retail video preview plays slowly frame by frame while out.mp4 is smooth
The speed of the complete chain of the retail model is lower than the frame rate of the original video. For example, when the source video is 30 FPS and Retail DINO plus the second-level recognition can only process it slowly, the file source can be back-pressured by the downstream pipeline: the program slows down the file reading and advancing speed while it waits for the previous frame to finish the inference.
xxxxxxxxxxLocal video file → inference slows down → file reading slows down accordingly → each frame is processed in turn
Therefore the preview window looks like a slow frame-by-frame playback, but it is still processing the complete video frames in order. The output MP4 keeps the original video timestamps and the player plays it on the normal timeline, so out.mp4 looks continuous and smooth.
This is not “automatically reducing the number of pushed-in frames” or actively dropping video frames; the file input can wait for the inference to complete. For a local video the cost is a longer total processing time; the same method cannot be used for a real-time camera, because the camera does not pause its output.
When you stop early during a local video, press Ctrl+C once and wait for the EOS finishing message to appear in the terminal before you exit. The program lets the MP4 muxer finish writing the moov index; do not press Ctrl+C repeatedly, close the terminal directly or use kill -9, otherwise out.mp4 may not be playable.
5. Real-time recognition with the USB camera
5.1 Run
xcd ~/deepstream_tao_apps/apps/tao_others/deepstream-mdx-perception-appexport DISPLAY=:0sudo -E ./deepstream-mdx-perception-app \-c ../../../configs/app/peoplenet_reidentification_usb.yml \-m 2 --tiledtext
The current USB mode uses sources_usb.csv by default:

xxxxxxxxxxenable,type,camera-width,camera-height,camera-fps-n,camera-fps-d,camera-v4l2-dev-node1,1,640,480,15,1,0
That is /dev/video0, 640×480, 15 FPS.
5.2 About Retail
The current course entry does not have the Retail Object Recognition model deployed yet, so -m 3 cannot be used directly. If you need to test the Retail pipeline, you must download the Retail Recognition model separately and put it under ~/deepstream_tao_apps/models/.
6. Real-time recognition with the CSI camera
6.1 Run
Run:
xxxxxxxxxx~/deepstream_tao_demo/run_mdx.sh csi

The script generates a temporary CSI CSV under /tmp/deepstream_tao/ and does not modify the repository template:
xxxxxxxxxxenable,type,camera-width,camera-height,camera-fps-n,camera-fps-d,camera-csi-sensor-id1,5,1920,1080,30,1,0
That is sensor-id=0, 1920×1080, 30 FPS. MDX directly uses the Argus type=5 and does not wrongly read /dev/video10.
7. Stopping, video output and troubleshooting
The real-time USB/CSI mode by default only previews and writes JSONL, and does not generate an out.mp4. The local video mode generates an out.mp4.
When you stop a real-time camera or a file task:
Go back to the terminal where the startup command runs.
Press
Ctrl+Conly once.Wait for
Received EOS. Exiting ...orApp run successfulbefore closing the terminal.
| Symptom | What to check first |
|---|---|
| No JSONL records in the people mode | Whether any people actually appear in the frame; no embedding is generated when there is no detected target. |
| No picture with USB | Run v4l2-ctl -d /dev/video0 --list-formats-ext and check the device number, the output format and whether it is occupied. |
| No picture with CSI | First confirm that the basic CSI case works, then check sensor-id=0 and nvargus-daemon. |
out.mp4 cannot be played | Use run_mdx.sh video; the script cleans up the old file first and automatically runs ffprobe to verify the container after it exits. |
VNC shows nothing | Use sudo -E to keep the DISPLAY environment variable; do not use a bare sudo. |
| It reports that the Retail Recognition model is missing | -m 3 is not available; the current environment only runs -m 2 (People ReID). |