Skip to content

Commit

Permalink
interpreter: Guard against missing left/right timing marks (#3736)
Browse files Browse the repository at this point in the history
* interpreter: Guard against missing left/right timing marks

* Fix light strip interp sketch
  • Loading branch information
jonahkagan authored Jul 18, 2023
1 parent 0b9ce7f commit 00cc9ee
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions libs/ballot-interpreter-nh/src/timing_marks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,15 +403,14 @@ pub fn find_timing_mark_shapes(
let candidate_timing_marks = contours
.iter()
.enumerate()
.filter_map(|(i, contour)| {
.filter_map(|(_i, contour)| {
if contour.border_type == BorderType::Hole {
let contour_bounds = get_contour_bounding_rect(contour).offset(
-PixelPosition::from(BORDER_SIZE),
-PixelPosition::from(BORDER_SIZE),
);
if rect_could_be_timing_mark(geometry, &contour_bounds)
&& is_contour_rectangular(contour)
&& contours.iter().all(|c| c.parent != Some(i))
{
return Some(contour_bounds);
}
Expand Down Expand Up @@ -697,6 +696,13 @@ pub fn find_complete_timing_marks_from_partial_timing_marks(
let left_line = &partial_timing_marks.left_rects;
let right_line = &partial_timing_marks.right_rects;

let min_left_right_timing_marks = (geometry.grid_size.height as f32 * 0.25).ceil() as usize;
if left_line.len() < min_left_right_timing_marks
|| right_line.len() < min_left_right_timing_marks
{
return None;
}

let mut horizontal_distances = vec![];
horizontal_distances.append(&mut distances_between_rects(top_line));
horizontal_distances.append(&mut distances_between_rects(bottom_line));
Expand Down

0 comments on commit 00cc9ee

Please sign in to comment.