quarree100 / qScope_frontend

Code for the projection of Q-Scope/CityScope@QUARREE100
0 stars 0 forks source link

blit transformed mouse position #26

Closed dunland closed 2 years ago

dunland commented 2 years ago

in verbose mode [ v ], display mouse position as transformed via grid_1.surface

        dst = np.float32([[0, 1080], [1920, 1080], [1920, 0], [0, 0]])
        src = np.float32(viewport.dst_points)
        perspective_transform = cv2.getPerspectiveTransform(src, dst)
        (x_size, y_size) = canvas_size
        pts = np.float32(np.array([[[mouse_pos[0] / x_size, mouse_pos[1] / y_size]]]))
        warped_pt = cv2.perspectiveTransform(pts, viewport.transform_mat)[0]
        print ("warped_pt = ", warped_pt)

        canvas.blit(font.render(str(warped_pt), True, (255,255,255)), (300,830))
        canvas.blit(font.render(str([mouse_pos[0] / x_size, mouse_pos[1] / y_size]), True, (255,255,255)), (300,850))

this should be very helpful to know the positions in order to draw polygons onto that surface

dunland commented 2 years ago

not really necessary at the moment. It was formerly thought to be helpful when creating custom shapes etc; now I render all shapes on the grid's surface and transform them using the grid's surface's transform matrix.