fix: helios dac homography should work
This commit is contained in:
parent
80c76bfeb1
commit
6c73bd9fc2
@ -68,6 +68,7 @@ GridDisplay = [0,0,0,0]
|
||||
|
||||
# Transformation Matrix for each laser
|
||||
EDH = [[], [], [], []]
|
||||
# EDH = [[], [], [], []]
|
||||
|
||||
# Etherdreams reports
|
||||
# ipconn is initial newdac to its etherdream
|
||||
|
@ -150,12 +150,13 @@ def find_affine(points1,points2):
|
||||
H[2,2] = 1
|
||||
return H
|
||||
|
||||
def apply(H,points):
|
||||
p = np.ones((len(points),2),'float64')
|
||||
p[:,:2] = points
|
||||
pp = np.dot(p,H.T)
|
||||
pp[:,:2]/=pp[:,2].reshape(len(p),1)
|
||||
return pp[:,:2]
|
||||
|
||||
def apply(H, points):
|
||||
p = np.ones((len(points), 3), 'float64')
|
||||
p[:, :3] = points
|
||||
pp = np.dot(p, H.T)
|
||||
pp[:, :2] /= pp[:, 2].reshape(len(p), 1)
|
||||
return pp[:, :2]
|
||||
|
||||
# Align and axis swap corrections
|
||||
# Reference points
|
||||
|
@ -95,13 +95,9 @@ class Status(object):
|
||||
print(prefix + l)
|
||||
|
||||
|
||||
def OnePointIterator(pl):
|
||||
def OnePointIterator(ref):
|
||||
while True:
|
||||
for indexpoint, currentpoint in enumerate(pl):
|
||||
print("cp", indexpoint, currentpoint)
|
||||
yield currentpoint[0], currentpoint[1], 255, 255, 255
|
||||
continue
|
||||
for indexpoint, currentpoint in enumerate(pl):
|
||||
for indexpoint, currentpoint in enumerate(ref.pl):
|
||||
|
||||
# We modify the point geometry according to warp settings
|
||||
# print indexpoint, currentpoint
|
||||
@ -327,7 +323,7 @@ class Tracer(object):
|
||||
# pdb.set_trace()
|
||||
# How much room?
|
||||
capacity = self.get_points_capacity()
|
||||
iterator = iter(OnePointIterator(self.pl))
|
||||
iterator = iter(OnePointIterator(self))
|
||||
|
||||
self.redis.set('/cap/' + str(self.laser_id), capacity)
|
||||
points = [next(iterator) for i in range(capacity)]
|
||||
|
@ -1,4 +1,5 @@
|
||||
import ctypes
|
||||
import math
|
||||
import random
|
||||
|
||||
from libs3 import gstt
|
||||
@ -33,7 +34,7 @@ class TracerHelios(Tracer):
|
||||
self.redis = redis
|
||||
self.laser_id = laser_id
|
||||
self.PL = PL
|
||||
self.pl = [[0,0,0]]
|
||||
self.pl = [[0, 0, 0]]
|
||||
self.clientkey = self.redis.get("/clientkey").decode('ascii')
|
||||
self.xyrgb = self.xyrgb_prev = (0, 0, 0, 0, 0)
|
||||
self.intensity = 65280
|
||||
@ -50,7 +51,7 @@ class TracerHelios(Tracer):
|
||||
pass
|
||||
|
||||
def get_points_capacity(self):
|
||||
return 10
|
||||
return 1000
|
||||
|
||||
# def GetPoints(self, capacity):
|
||||
# a = [2,3]
|
||||
@ -80,20 +81,14 @@ class TracerHelios(Tracer):
|
||||
return True
|
||||
|
||||
def write(self, points):
|
||||
# status_attempts = 0
|
||||
# j = 0
|
||||
# while (status_attempts < 512 and HeliosLib.GetStatus(j) != 1):
|
||||
# status_attempts += 1
|
||||
# print("attempt {}".format(status_attempts))
|
||||
# HeliosLib.WriteFrame(j, 3000, 0, ctypes.pointer(frames[i % 30]), 1000) # Send the frame
|
||||
frame_type = HeliosPoint * self.get_points_capacity()
|
||||
frame = frame_type()
|
||||
helios_id = 0
|
||||
# print("hello got {} points".format(len(points)))
|
||||
points = [point for point in points]
|
||||
for i, point in enumerate(points):
|
||||
x, y, r, g, b = point
|
||||
print(x,y,r,g,b)
|
||||
x = x if not math.isnan(x) else 0
|
||||
y = x if not math.isnan(y) else 0
|
||||
frame[i] = HeliosPoint(int(x), int(y), int(r), int(g), int(b), 255)
|
||||
statusAttempts = 0
|
||||
# Make 512 attempts for DAC status to be ready. After that, just give up and try to write the frame anyway
|
||||
@ -101,15 +96,19 @@ class TracerHelios(Tracer):
|
||||
statusAttempts += 1
|
||||
f = ctypes.pointer(frame)
|
||||
# int HeliosDac::WriteFrame(unsigned int devNum, unsigned int pps, std::uint8_t flags, HeliosPoint* points, unsigned int numOfPoints)
|
||||
r = HeliosLib.WriteFrame(0, 300, 0, f, len(frame))
|
||||
ret_helios = HeliosLib.WriteFrame(0, 3000, 0, f, len(frame))
|
||||
# @todo : detect errors
|
||||
if ret_helios != 1:
|
||||
print(f"ERR ]Helios DAC #{self.laser_id} returned error {ret_helios}")
|
||||
|
||||
def get_warped_point(self, x, y):
|
||||
|
||||
# transform in one matrix, with warp !!
|
||||
# Etherpoint all transform in one matrix, with warp !!
|
||||
# position = homographyp.apply(gstt.EDH[self.laser_id], np.array([(x, y)]))
|
||||
return x, y
|
||||
# return position[0][0], position[0][1]
|
||||
np_arr = np.array([(x, y, 0)])
|
||||
laser_EDH = gstt.EDH[self.laser_id]
|
||||
position = homographyp.apply(laser_EDH, np_arr)
|
||||
return position[0][0], position[0][1]
|
||||
|
||||
#
|
||||
# # Create sample frames
|
||||
|
Loading…
Reference in New Issue
Block a user