本文整理汇总了Python中models.Box.is_complete方法的典型用法代码示例。如果您正苦于以下问题:Python Box.is_complete方法的具体用法?Python Box.is_complete怎么用?Python Box.is_complete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Box
的用法示例。
在下文中一共展示了Box.is_complete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Scanner
# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import is_complete [as 别名]
#.........这里部分代码省略.........
# Capture frame with laser off
self.set_laser(False)
time.sleep(0.2)
frame_no_laser = self._capture_frame()
frame_diff = self.red_filter(cv2.absdiff(frame, frame_no_laser))
self.display_image = frame_diff
if not thresholded:
return frame_diff
blue, green, red = cv2.split(frame_diff)
retval, thresholded = cv2.threshold(red, self.laser_threshold, 255, cv2.THRESH_BINARY)
return thresholded
def get_laser_plane_intersection(self, v):
""" Calculates the intersection of a vector with the laser plane.
The camera position is represented by the vector [0, c_y, c_z], where c_y and c_z are the camera coordinates.
c_y should be negative, as the y axis is positive away from the camera, starting at the platform middle.
The plane is represented by the plane created by the vectors [1,1,0] and [0,0,1]
"""
c_y, c_z = self.camera_position[1:3]
x, y, z = v[:3]
lam = c_y/(x-y)
return array([
lam*x,
lam*y + c_y,
lam*z + c_z
])
return v + array([0, ])
def process_frame(self, thresholded_frame):
if self.area and self.area.is_complete:
thresholded_frame = thresholded_frame[self.area.y1:self.area.y2, self.area.x1:self.area.x2]
processed_frame = Frame()
points = numpy.transpose(thresholded_frame.nonzero())
if not len(points):
return
# Precalculations
tan_half_fov_x = math.tan(self.fov_x/2)
tan_half_fov_y = math.tan(self.fov_y/2)
# m is the vector from the camera position to the origin
m = self.camera_position * -1
w = self.width/2
h = self.height/2
for point in points:
img_y, img_x = point
if self.area and self.area.is_complete:
img_y += self.area.y1
img_x += self.area.x1
# Horizontal angle between platform middle (in image) and point
delta_x = float(img_x - self.platform_middle[0])/2
tau = math.atan(delta_x/w*tan_half_fov_x)
# Vertical angle
delta_y = float(img_y - self.platform_middle[1])/2
rho = math.atan(delta_y/h*tan_half_fov_y)