F
Member
A detector can identify a part correctly while the robot's reconstructed ray or pick position is systematically wrong. One possible cause is a coordinate mismatch introduced entirely in software: detections are expressed in a cropped, resized or padded image, but the next stage interprets them using the original camera coordinates.
Recalibrating the physical camera will not repair a preprocessing transform that was omitted from the geometric interface.
### Name the pixel domain at every boundary
A network input may be produced by cropping a region of interest, resizing it and adding letterbox padding. Its pixel origin and scale can differ from those of the acquired image. Normalised detector coordinates introduce another conversion, and the output decoder may already undo some of these steps.
For a simple affine pixel mapping, write the actual relationship explicitly:
`u_network = s_x * u_camera + b_x`
`v_network = s_y * v_camera + b_y`
The offsets include the effects of crop and padding under the chosen coordinate convention. Subpixel work also requires agreement on pixel-centre and resize conventions; dimensions alone do not establish the exact mapping.
There are two consistent approaches: map detected points back into the original image domain and use its camera model, or transform the camera matrix into the processed domain. In homogeneous coordinates, if `p_network = A * p_camera`, the corresponding pinhole matrix is `K_network = A * K_camera` for this known image-coordinate transform.
The official [OpenCV calibration tutorial](https://docs.opencv.org/4.x/d4/d94/tutorial_camera_calibration.html) defines focal lengths and principal point in pixel coordinates and discusses adapting the camera matrix to resolution. The crop and padding terms still need to come from the actual application's preprocessing pipeline.
### Do not undo a transform twice
Some model wrappers return detections already mapped to source-image coordinates. Applying the inverse letterbox transform again creates a different systematic error. Record what the decoder returns, not merely what the model's raw tensor represents.
Rectification is another boundary. A point on an undistorted image belongs with the rectified camera model. Applying the original distortion correction again, or mixing rectified coordinates with the raw-image matrix, is not fixed by adjusting a resize factor.
### Test geometry without asking the detector to be correct
Inject known image points into the postprocessing path and compare them with independently specified expected locations. Useful tests include:
- Centre and corner points with a nonzero crop offset.
- Unequal horizontal and vertical scaling where the pipeline permits it.
- Letterbox padding on each relevant side, including rounded output dimensions.
- Normalised versus pixel-valued detector outputs.
- Raw and rectified image paths with their distinct camera models.
A forward/inverse round trip is useful, but two functions can share the same wrong convention. Include independently calculated cases and a reprojection overlay on the original saved image. Keep the acquisition image, network input, decoded points and final geometric inputs together in the diagnostic package.
### Make preprocessing part of the geometric release
Version the transform metadata with the model wrapper and camera configuration. A runtime ROI change must reach every consumer that interprets detections geometrically. A fixed preprocessing pipeline is easier to audit; adaptive crops can improve efficiency but require per-frame transform provenance.
These checks establish coordinate consistency, not detection accuracy or permission to execute a grasp.
**Open engineering question:** could a downstream consumer determine the exact image domain of every returned point without reading the detector's implementation? Which test catches an omitted crop offset or a second inverse resize before the robot moves?
Recalibrating the physical camera will not repair a preprocessing transform that was omitted from the geometric interface.
### Name the pixel domain at every boundary
A network input may be produced by cropping a region of interest, resizing it and adding letterbox padding. Its pixel origin and scale can differ from those of the acquired image. Normalised detector coordinates introduce another conversion, and the output decoder may already undo some of these steps.
For a simple affine pixel mapping, write the actual relationship explicitly:
`u_network = s_x * u_camera + b_x`
`v_network = s_y * v_camera + b_y`
The offsets include the effects of crop and padding under the chosen coordinate convention. Subpixel work also requires agreement on pixel-centre and resize conventions; dimensions alone do not establish the exact mapping.
There are two consistent approaches: map detected points back into the original image domain and use its camera model, or transform the camera matrix into the processed domain. In homogeneous coordinates, if `p_network = A * p_camera`, the corresponding pinhole matrix is `K_network = A * K_camera` for this known image-coordinate transform.
The official [OpenCV calibration tutorial](https://docs.opencv.org/4.x/d4/d94/tutorial_camera_calibration.html) defines focal lengths and principal point in pixel coordinates and discusses adapting the camera matrix to resolution. The crop and padding terms still need to come from the actual application's preprocessing pipeline.
### Do not undo a transform twice
Some model wrappers return detections already mapped to source-image coordinates. Applying the inverse letterbox transform again creates a different systematic error. Record what the decoder returns, not merely what the model's raw tensor represents.
Rectification is another boundary. A point on an undistorted image belongs with the rectified camera model. Applying the original distortion correction again, or mixing rectified coordinates with the raw-image matrix, is not fixed by adjusting a resize factor.
### Test geometry without asking the detector to be correct
Inject known image points into the postprocessing path and compare them with independently specified expected locations. Useful tests include:
- Centre and corner points with a nonzero crop offset.
- Unequal horizontal and vertical scaling where the pipeline permits it.
- Letterbox padding on each relevant side, including rounded output dimensions.
- Normalised versus pixel-valued detector outputs.
- Raw and rectified image paths with their distinct camera models.
A forward/inverse round trip is useful, but two functions can share the same wrong convention. Include independently calculated cases and a reprojection overlay on the original saved image. Keep the acquisition image, network input, decoded points and final geometric inputs together in the diagnostic package.
### Make preprocessing part of the geometric release
Version the transform metadata with the model wrapper and camera configuration. A runtime ROI change must reach every consumer that interprets detections geometrically. A fixed preprocessing pipeline is easier to audit; adaptive crops can improve efficiency but require per-frame transform provenance.
These checks establish coordinate consistency, not detection accuracy or permission to execute a grasp.
**Open engineering question:** could a downstream consumer determine the exact image domain of every returned point without reading the detector's implementation? Which test catches an omitted crop offset or a second inverse resize before the robot moves?