VISCORE
← All works

Vision & Edge AIJul – Aug 2026Completed

Real-Time Detection Pipeline for an Industrial Camera

A real-time C++ pipeline on a Jetson Orin NX Super, from industrial-camera capture to TensorRT detection.

Sole developer

  • Jetson Orin NX Super
  • JetPack 6.2.2
  • TensorRT 10
  • C++
  • OpenCV
  • Hikrobot MVS SDK
  • Docker
Edge-debug window of the C++ vision program
7.9 msEngine-only inferenceYOLOv8-face · TensorRT FP16 · Orin NX Super · trtexec figure, excluding capture and pre/post-processing

Background

A model that runs in Python is still a long way from an on-device vision system that stays up for hours. The goal here was to make the whole chain run in real time in C++ on the board. Three constraints applied: the industrial camera is not a UVC device, so OpenCV cannot open it; the model takes 640×640 input while the camera delivers 1440×1080; and the board had to be set up from a fresh flash.

What the system does

Hikrobot industrial camera→C++ capture→letterbox preprocessing→TensorRT FP16 inference→coordinate mapping→boxes on the original frame
  • Grabs frames from a USB3 industrial camera in real time
  • Runs detection on the device and maps boxes back to original-frame coordinates
  • Runs entirely in C++, with no Python runtime

My work

  • Device environment: flashed JetPack 6.2.2 and configured CUDA and the Docker GPU runtime, building the development and deployment environment from scratch.
  • Capture module: wrote C++ capture on the Hikrobot MVS SDK, converting frames straight into OpenCV Mat. An industrial camera cannot be opened with cv2.VideoCapture; the vendor SDK is the only route.
  • Model deployment: exported YOLOv8-face to ONNX and built the FP16 engine with trtexec on the target board. Engines are tied to the device, so they have to be built there.
  • Pre- and post-processing: implemented letterbox (proportional resize, then grey padding); after inference, subtract the padding first and divide by the scale second to restore boxes to the original frame, then clamp to the image bounds.
  • Profiling: timed each stage separately to find where the time goes.

Problems and fixes

Every box was offset. Boxes either flew around or sat a fixed distance off. I split the problem into two halves and verified each, which turned up two causes: the padding subtraction and the scale division were in the wrong order, and the output tensor is laid out by channel, so reading it row by row per candidate misaligns everything. The two bugs look almost identical and had to be isolated one at a time.

CUDA NMS missing inside the container. Another package had replaced torchvision in the image with a build that has no CUDA operators, so NMS failed outright. Pinning the version that matches JetPack restored it.

Results

  • The whole chain runs in real time in C++: capture, preprocessing, inference, coordinate mapping, drawing.
  • TensorRT FP16 engine-only inference takes 7.9 ms (YOLOv8-face, trtexec figure, excluding capture and pre/post-processing).

Retrospective

  • Profiling shows the bottleneck is CPU preprocessing (a triple loop), not the engine. The next step is to move preprocessing to the GPU and split capture, inference and display into a pipeline.
  • I kept no quantitative record of how many pixels the boxes were off while fixing the offset; the debugging table follows the code structure instead.
  • Software/hardware triggering and external-sensor integration are not done yet.
Technical notes
  • Environment: JetPack 6.2.2, CUDA and the Docker GPU runtime; the FP16 engine is built with trtexec on the target board.
  • Sizes: 640×640 model input, 1440×1080 camera frame.
  • Output tensor: [1, 5, 8400], laid out by channel; the confidence of candidate i is at output[4 * N + i].
  • Container: torchvision must be pinned to the version matching JetPack, otherwise the CUDA NMS operator is missing.