Display current frame with points
(self)
| 362 | ) |
| 363 | |
| 364 | def display_frame(self): |
| 365 | """Display current frame with points""" |
| 366 | frame = self.get_current_frame() |
| 367 | if frame is None: |
| 368 | return |
| 369 | |
| 370 | # Draw points for CURRENT frame |
| 371 | vis = frame.copy() |
| 372 | current_points = self.points_by_frame.get(self.current_frame_idx, []) |
| 373 | |
| 374 | for i, (x, y) in enumerate(current_points): |
| 375 | cv2.circle(vis, (x, y), self.point_radius, (255, 0, 0), -1) |
| 376 | cv2.circle(vis, (x, y), self.point_radius + 2, (255, 255, 255), 2) |
| 377 | cv2.putText(vis, str(i + 1), (x + 12, y + 12), cv2.FONT_HERSHEY_SIMPLEX, 0.6, (255, 255, 255), 2) |
| 378 | |
| 379 | # Show indicator if other frames have points |
| 380 | if len(self.points_by_frame) > 0: |
| 381 | other_frames = [f for f in self.points_by_frame.keys() if f != self.current_frame_idx] |
| 382 | if other_frames: |
| 383 | text = f"Other frames with points: {', '.join(map(str, sorted(other_frames)))}" |
| 384 | cv2.putText(vis, text, (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 0.6, (0, 255, 255), 2) |
| 385 | |
| 386 | # Scale for display |
| 387 | h, w = vis.shape[:2] |
| 388 | max_width, max_height = 800, 450 |
| 389 | scale_w = max_width / w |
| 390 | scale_h = max_height / h |
| 391 | self.display_scale = min(scale_w, scale_h, 1.0) |
| 392 | |
| 393 | new_w = int(w * self.display_scale) |
| 394 | new_h = int(h * self.display_scale) |
| 395 | vis_resized = cv2.resize(vis, (new_w, new_h)) |
| 396 | |
| 397 | # Convert to PIL and display |
| 398 | pil_img = Image.fromarray(vis_resized) |
| 399 | self.photo = ImageTk.PhotoImage(pil_img) |
| 400 | self.canvas.delete("all") |
| 401 | self.canvas.create_image(0, 0, anchor=tk.NW, image=self.photo) |
| 402 | |
| 403 | self.point_count_label.config(text=f"Pts on F{self.current_frame_idx}: {len(current_points)}") |
| 404 | |
| 405 | def on_canvas_click(self, event): |
| 406 | """Handle click on canvas - add point to CURRENT frame""" |
no test coverage detected