本文整理匯總了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)