display debug points from homography
This commit is contained in:
parent
0af5030845
commit
e6187964d3
4 changed files with 42 additions and 15 deletions
|
@ -22,6 +22,7 @@ import math
|
|||
from pyglet import shapes
|
||||
|
||||
from PIL import Image
|
||||
import json
|
||||
|
||||
from trap.frame_emitter import DetectionState, Frame, Track
|
||||
from trap.preview_renderer import DrawnTrack, PROJECTION_IMG, PROJECTION_MAP
|
||||
|
@ -115,6 +116,26 @@ class AnimationRenderer:
|
|||
|
||||
]
|
||||
|
||||
self.debug_points = []
|
||||
# print(self.config.debug_points_file)
|
||||
if self.config.debug_points_file:
|
||||
with self.config.debug_points_file.open('r') as fp:
|
||||
img_points = np.array(json.load(fp))
|
||||
# to place points accurate I used a 2160p image, but during calibration and
|
||||
# prediction I use(d) a 1440p image, so convert points to different space:
|
||||
img_points = np.array(img_points)
|
||||
# first undistort the points so that lines are actually straight
|
||||
undistorted_img_points = cv2.undistortPoints(np.array([img_points]).astype('float32'), self.config.camera.mtx, self.config.camera.dist, None, self.config.camera.newcameramtx)
|
||||
dst_img_points = cv2.perspectiveTransform(np.array(undistorted_img_points), self.config.camera.H)
|
||||
if dst_img_points.shape[1:] == (1,2):
|
||||
dst_img_points = np.reshape(dst_img_points, (dst_img_points.shape[0], 2))
|
||||
|
||||
self.debug_points = [
|
||||
pyglet.shapes.Circle(p[0], self.window.height - p[1], 3, color=(255,0,0,255), batch=self.batch_overlay) for p in dst_img_points
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
self.init_shapes()
|
||||
|
||||
|
|
|
@ -326,3 +326,9 @@ render_parser.add_argument("--render-url",
|
|||
type=str,
|
||||
default=None)
|
||||
|
||||
|
||||
render_parser.add_argument("--debug-points-file",
|
||||
help="A json file with points to test projection/homography etc.",
|
||||
type=Path,
|
||||
required=False,
|
||||
)
|
|
@ -215,7 +215,6 @@ class FrameEmitter:
|
|||
i = self.config.video_offset
|
||||
|
||||
|
||||
|
||||
# if '-' in video_path.path().stem:
|
||||
# path_stem = video_path.stem[:video_path.stem.rfind('-')]
|
||||
# else:
|
||||
|
|
|
@ -111,6 +111,7 @@ class DrawnTrack:
|
|||
if len(self.coords) > len(self.drawn_positions):
|
||||
self.drawn_positions.extend(self.coords[len(self.drawn_positions):])
|
||||
|
||||
if len(self.pred_coords):
|
||||
for a, drawn_prediction in enumerate(self.drawn_predictions):
|
||||
for i, pos in enumerate(drawn_prediction):
|
||||
# TODO: this should be done in polar space starting from origin (i.e. self.drawn_posision[-1])
|
||||
|
|
Loading…
Reference in a new issue