mirror of
https://github.com/azaion/autopilot.git
synced 2026-06-22 17:01:11 +00:00
[AZ-662] [AZ-669] Close batch 19: green test gate via Jetson Docker
ci/woodpecker/push/build-arm Pipeline failed
ci/woodpecker/push/build-arm Pipeline failed
Stand up a production-target test runner on jetson-e2e and run the deferred cargo test --workspace for batch 19. Infra: - Dockerfile.test: ubuntu:22.04 + libopencv-dev + libav*-dev + libclang-dev + protobuf-compiler + rust 1.82.0 (rustfmt, clippy). Sets LIBCLANG_PATH so clang-sys can dlopen libclang under the opencv-rust clang-runtime path. - scripts/jetson-test.sh: rsync source to jetson-e2e, docker build, docker run cargo test --workspace --no-fail-fast. Workspace fix exposed by the gate: - Cargo.toml: enable opencv "clang-runtime" feature. Without it the workspace fails to build because clang-sys is shared between opencv-binding-generator and bindgen (via ffmpeg-sys-next) and the opencv generator panics with "a `libclang` shared library is not loaded on this thread" (opencv-rust GH issue #635). Batch-19 code bugs exposed by the gate (6 compile errors + 1 algo bug): - movement_detector::optical_flow: min_max_loc signature (opencv 0.98 expects Option<&mut f64> / Option<&mut Point>); data_mut() returns *mut u8 directly, not Result. RANSAC residual now filters by the inlier mask returned by find_homography (matches the docstring; was systematically over-reporting motion magnitude on synthetic pure-pan input). - semantic_analyzer::scoring::freshness: same data_mut() fix; stddev_f32 now takes &impl core::ToInputArray so it accepts the BoxedRef<Mat> that Mat::roi returns in opencv 0.98. Result: 391 tests passed across 58 binaries, 0 in-scope failures. Two pre-existing failures in frame_ingest (batch 16-18 scope) are NOT addressed here and are recorded as leftovers: - frame_ingest_cuvid_segv: HIGH severity production bug; libavcodec58 advertises h264_cuvid but libnvcuvid.so.1 is missing at runtime, the software fallback never fires, first send_packet SEGVs. - frame_ingest_publisher_timing_flake: LOW severity; Jetson-specific timing budget too tight for ac1_three_consumers_at_rate_lose_no_frames. Neither blocks batch 20 (movement_detector / semantic_analyzer next). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -38,10 +38,10 @@ pub fn is_degenerate(gray: &Mat) -> opencv::Result<bool> {
|
||||
let mut max_val = 0.0f64;
|
||||
core::min_max_loc(
|
||||
gray,
|
||||
&mut min_val,
|
||||
&mut max_val,
|
||||
&mut core::Point::default(),
|
||||
&mut core::Point::default(),
|
||||
Some(&mut min_val),
|
||||
Some(&mut max_val),
|
||||
None,
|
||||
None,
|
||||
&core::no_array(),
|
||||
)?;
|
||||
Ok((max_val - min_val) < 10.0)
|
||||
@@ -66,8 +66,9 @@ pub fn frame_to_gray(frame: &Frame) -> opencv::Result<Mat> {
|
||||
h, w, core::CV_8UC3, core::Scalar::all(0.0),
|
||||
)?;
|
||||
// SAFETY: rgb_mat is a freshly allocated continuous Mat; no aliasing.
|
||||
// `data_mut()` returns `*mut u8` directly in opencv 0.98 (no Result).
|
||||
let mat_data = unsafe {
|
||||
std::slice::from_raw_parts_mut(rgb_mat.data_mut()?, rgb_len)
|
||||
std::slice::from_raw_parts_mut(rgb_mat.data_mut(), rgb_len)
|
||||
};
|
||||
mat_data.copy_from_slice(&data[..rgb_len]);
|
||||
let mut gray = Mat::default();
|
||||
@@ -81,8 +82,9 @@ fn copy_bytes_to_gray_mat(src: &[u8], w: i32, h: i32) -> opencv::Result<Mat> {
|
||||
let mut mat =
|
||||
Mat::new_rows_cols_with_default(h, w, core::CV_8UC1, core::Scalar::all(0.0))?;
|
||||
// SAFETY: mat is a freshly allocated continuous Mat; no aliasing.
|
||||
// `data_mut()` returns `*mut u8` directly in opencv 0.98 (no Result).
|
||||
let mat_data = unsafe {
|
||||
std::slice::from_raw_parts_mut(mat.data_mut()?, src.len())
|
||||
std::slice::from_raw_parts_mut(mat.data_mut(), src.len())
|
||||
};
|
||||
mat_data.copy_from_slice(src);
|
||||
Ok(mat)
|
||||
@@ -169,10 +171,26 @@ pub fn estimate_homography(
|
||||
}
|
||||
}
|
||||
|
||||
// 6. Mean reprojection residual across all tracked inliers.
|
||||
// 6. Mean reprojection residual across RANSAC inliers ONLY.
|
||||
//
|
||||
// `find_homography(..., RANSAC, 3.0)` populates `mask` with 1 for
|
||||
// inlier point pairs (consistent with the fitted homography to
|
||||
// within 3 px) and 0 for outliers. Including outliers in the
|
||||
// residual would defeat the purpose of RANSAC: a synthetic pure
|
||||
// pan can have edge features whose LK-tracked flow is off by the
|
||||
// shift amount (the post-shift region falls outside the original
|
||||
// frame); those points become RANSAC outliers and would otherwise
|
||||
// inflate the residual by several pixels.
|
||||
let mut total = 0.0f32;
|
||||
let mut count = 0u32;
|
||||
for i in 0..good_prev.len() {
|
||||
let is_inlier = mask
|
||||
.at_2d::<u8>(i as i32, 0)
|
||||
.map(|v| *v != 0)
|
||||
.unwrap_or(false);
|
||||
if !is_inlier {
|
||||
continue;
|
||||
}
|
||||
let p = good_prev.get(i)?;
|
||||
let c = good_curr.get(i)?;
|
||||
let x = p.x as f64;
|
||||
|
||||
@@ -53,7 +53,8 @@ fn frame_to_gray_mat(frame: &Frame) -> opencv::Result<Mat> {
|
||||
let y_len = (w * h) as usize;
|
||||
let mut mat = Mat::new_rows_cols_with_default(h, w, core::CV_8UC1, Scalar::all(0.0))?;
|
||||
// SAFETY: freshly allocated continuous Mat; no aliasing.
|
||||
let dst = unsafe { std::slice::from_raw_parts_mut(mat.data_mut()?, y_len) };
|
||||
// `data_mut()` returns `*mut u8` directly in opencv 0.98 (no Result).
|
||||
let dst = unsafe { std::slice::from_raw_parts_mut(mat.data_mut(), y_len) };
|
||||
dst.copy_from_slice(&data[..y_len]);
|
||||
Ok(mat)
|
||||
}
|
||||
@@ -61,7 +62,7 @@ fn frame_to_gray_mat(frame: &Frame) -> opencv::Result<Mat> {
|
||||
let rgb_len = (w * h * 3) as usize;
|
||||
let mut rgb =
|
||||
Mat::new_rows_cols_with_default(h, w, core::CV_8UC3, Scalar::all(0.0))?;
|
||||
let dst = unsafe { std::slice::from_raw_parts_mut(rgb.data_mut()?, rgb_len) };
|
||||
let dst = unsafe { std::slice::from_raw_parts_mut(rgb.data_mut(), rgb_len) };
|
||||
dst.copy_from_slice(&data[..rgb_len]);
|
||||
let mut gray = Mat::default();
|
||||
imgproc::cvt_color(&rgb, &mut gray, imgproc::COLOR_RGB2GRAY, 0)?;
|
||||
@@ -128,7 +129,9 @@ fn variance(mat: &Mat) -> opencv::Result<f64> {
|
||||
Ok(std * std)
|
||||
}
|
||||
|
||||
fn stddev_f32(mat: &Mat) -> opencv::Result<f32> {
|
||||
// Accept `&impl ToInputArray` so both `&Mat` and `&BoxedRef<Mat>` (returned
|
||||
// by `Mat::roi` in opencv 0.98) can be passed without manual deref.
|
||||
fn stddev_f32(mat: &impl core::ToInputArray) -> opencv::Result<f32> {
|
||||
let mut mean_mat = Mat::default();
|
||||
let mut stddev_mat = Mat::default();
|
||||
core::mean_std_dev(mat, &mut mean_mat, &mut stddev_mat, &core::no_array())?;
|
||||
|
||||
Reference in New Issue
Block a user