Commit 0f1a97e1 authored by Laurent Claustre's avatar Laurent Claustre

try to update beammark position when new RoI is set or reset

parent 42b7268e
Pipeline #17923 passed with stages
in 1 minute and 52 seconds
......@@ -244,7 +244,30 @@ class BVWebserver:
def setroi(self, camera):
try:
self.cameras_running[camera][0].image_roi = (int(bottle.request.query.x),int(bottle.request.query.y),int(bottle.request.query.w),int(bottle.request.query.h))
# calculate/get figures
x_range = range(int(bottle.request.query.x), int(bottle.request.query.x+bottle.request.query.w))
y_range = range(int(bottle.request.query.y), int(bottle.request.query.x+bottle.request.query.h))
bm_x = int(self.cameras_running[camera][1].beammark[0] * self.cameras_running[camera][1].calibration[0])
bm_y = int(self.cameras_running[camera][1].beammark[1] * self.cameras_running[camera][1].calibration[1])
_, _, cam_xsize,cam_ysize = self.cameras_running[camera][0].image_sizes
image_roi = self.cameras_running[camera][0].image_roi
# now apply the new RoI
self.cameras_running[camera][0].image_roi = (int(bottle.request.query.x),int(bottle.request.query.y), \
int(bottle.request.query.w),int(bottle.request.query.h))
# check and update beammark if possible
if int(bottle.request.query.w) == 0 and int(bottle.request.query.h):
# RoI has been reset, so up scale beammark position
bm_x = bm_x + image_roi[2]
bm_y = bm_y + image_roi[3]
else:
if bm_x in x_range and bm_y in y_range:
# new RoI, so down scale beammark position
bm_x = bm_x - int(bottle.request.query.x)
bm_y = bm_y - int(bottle.request.query.y)
else:
# beammark out of window
bm_x = bm_y = 0
self.cameras_running[camera][1].beammark = ([bm_x, bm_y])
return { "message": "Set roi" }
except Exception as e:
print ("Could not set roi", e)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment