本文整理汇总了Python中cv2.getTickCount方法的典型用法代码示例。如果您正苦于以下问题:Python cv2.getTickCount方法的具体用法?Python cv2.getTickCount怎么用?Python cv2.getTickCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cv2
的用法示例。
在下文中一共展示了cv2.getTickCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: replan
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import getTickCount [as 别名]
def replan(self):
print(colorize("===== Replan =====","red"))
if self.game_mode == "with_bias":
start_pos = self.current_pos
else:
start_pos = self.current_pos + self.pos_bias
start_pos = self.start_pos
self.narrow_gap.approach_trajectory(start_pos,
self.current_spd,
self.current_acc, if_draw=0)
self.narrow_gap.cross_ballistic_trajectory(if_draw=0);
self.approach_time = self.narrow_gap.Tf
self.cross_time = self.narrow_gap.t_c
final_target_rot = self.narrow_gap.get_rotation(self.approach_time + self.cross_time)
final_target_rot = self.transform_R_world_to_ned*final_target_rot
if (np.linalg.det(final_target_rot) == -1):
final_target_rot[:, 1] = final_target_rot[:, 1] * -1
self.final_rpy = transforms3d.euler.mat2euler( final_target_rot, axes = 'sxyz')
self.trajectory_start_t = cv2.getTickCount()
# Get observation
示例2: make_h5py
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import getTickCount [as 别名]
def make_h5py():
x_train_paths, y_train_paths = get_data('train')
x_val_paths, y_val_paths = get_data('val')
x_test_paths, y_test_paths = get_data('test')
h5py_file = h5py.File(os.path.join(dir_path, 'data.h5'), 'w')
start = cv2.getTickCount()
write_data(h5py_file, 'train', x_train_paths, y_train_paths)
time = (cv2.getTickCount()-start)/cv2.getTickFrequency()
print ('parsing train data, Time:%.3fs'%time)
start = cv2.getTickCount()
write_data(h5py_file, 'val', x_val_paths, y_val_paths)
time = (cv2.getTickCount()-start)/cv2.getTickFrequency()
print ('parsing val data, Time:%.3fs'%time)
start = cv2.getTickCount()
write_data(h5py_file, 'test', x_test_paths, y_test_paths)
time = (cv2.getTickCount()-start)/cv2.getTickFrequency()
print ('parsing test data, Time:%.3fs'%time)
示例3: control
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import getTickCount [as 别名]
def control(self):
self.current_time = (cv2.getTickCount() - self.t_start) / cv2.getTickFrequency()
self.pid_ctrl.update_target(self.target_pos.ravel().tolist()[0], self.target_spd.ravel().tolist()[0], self.target_acc.ravel().tolist()[0], target_yaw=0)
self.pid_ctrl.update_control()
self.gym_obs = self.env.step(np.array([self.pid_ctrl.tar_roll, self.pid_ctrl.tar_pitch, self.pid_ctrl.tar_thrust]))
self.refresh_state()
r, p, y = self.pid_rpy_to_air_sim_rpy(self.pid_ctrl.tar_roll, self.pid_ctrl.tar_pitch, self.pid_ctrl.tar_yaw)
throttle = self.pid_ctrl.tar_thrust/9.8
if (self.if_log):
self.logger.update("time_stamp", self.current_time)
self.logger.update("current_pos", self.current_pos)
self.logger.update("current_spd", self.current_spd)
self.logger.update("current_acc", self.current_acc)
self.logger.update("current_rot", self.current_rot)
self.logger.update("target_pos", self.target_pos)
self.logger.update("target_spd", self.target_spd)
self.logger.update("target_acc", self.target_acc)
self.logger.update("target_rot", self.target_rot)
self.logger.update("input_roll", r)
self.logger.update("input_pitch", p)
self.logger.update("input_yaw", y)
self.logger.update("input_throttle", throttle)
示例4: webcam_gui
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import getTickCount [as 别名]
def webcam_gui(filter_func, video_src=0):
cap = cv2.VideoCapture(video_src)
key_code = -1
while(key_code == -1):
t = cv2.getTickCount()
# read a frame
ret, frame = cap.read()
fps = cv2.getTickFrequency() / (cv2.getTickCount() - t)
print("Frame rate: " + str(fps))
# run filter with the arguments
frame_out = filter_func(frame)
# show the image
cv2.imshow('Press any key to exit', frame_out)
# wait for the key
key_code = cv2.waitKey(10)
cap.release()
cv2.destroyAllWindows()
示例5: clock
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import getTickCount [as 别名]
def clock():
return cv2.getTickCount() / cv2.getTickFrequency()
示例6: train_visualization_seg
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import getTickCount [as 别名]
def train_visualization_seg(self, model, epoch, path):
# image_name_list = sorted(glob(os.path.join(self.flag.data_path,'val/IMAGE/*/frankfurt_000000_014480_leftImg8bit.png')))
# print (image_name_list)
image_name = path #'./result/frankfurt_000000_014480_leftImg8bit.png'
image_height = self.flag.image_height
image_width = self.flag.image_width
imgInput = cv2.imread(image_name, self.flag.color_mode)
imgInput = cv2.cvtColor(imgInput, cv2.COLOR_BGR2RGB)
output_path = self.flag.output_dir
input_data = imgInput.reshape((1,image_height,image_width,self.flag.color_mode*2+1))
t_start = cv2.getTickCount()
result = model.predict(input_data, 1)
t_total = (cv2.getTickCount() - t_start) / cv2.getTickFrequency() * 1000
print ("[*] Predict Time: %.3f ms"%t_total)
imgMask = (result[0]*255).astype(np.uint8)
imgShow = cv2.cvtColor(imgInput, cv2.COLOR_RGB2BGR).copy()
#cv2.cvtColor(imgInput, cv2.COLOR_GRAY2BGR)
# imgMaskColor = cv2.applyColorMap(imgMask, cv2.COLORMAP_JET)
imgMaskColor = imgMask
imgShow = cv2.addWeighted(imgShow, 0.5, imgMaskColor, 0.6, 0.0)
output_path = os.path.join(self.flag.output_dir, '%04d_'%epoch+os.path.basename(image_name))
mask_path = os.path.join(self.flag.output_dir, 'mask_%04d_'%epoch+os.path.basename(image_name))
cv2.imwrite(output_path, imgShow)
cv2.imwrite(mask_path, imgMaskColor)
# print "SAVE:[%s]"%output_path
# cv2.imwrite(os.path.join(output_path, 'img%04d.png'%epoch), imgShow)
# cv2.namedWindow("show", 0)
# cv2.resizeWindow("show", 800, 800)
# cv2.imshow("show", imgShow)
# cv2.waitKey(1)
示例7: tracker
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import getTickCount [as 别名]
def tracker(cam, frame, bbox):
tracker = KCFTracker(True, True, True) # (hog, fixed_Window, multi_scale)
tracker.init(bbox, frame)
while True:
ok, frame = cam.read()
timer = cv2.getTickCount()
bbox = tracker.update(frame)
bbox = list(map(int, bbox))
fps = cv2.getTickFrequency() / (cv2.getTickCount() - timer)
# Tracking success
p1 = (int(bbox[0]), int(bbox[1]))
p2 = (int(bbox[0] + bbox[2]), int(bbox[1] + bbox[3]))
cv2.rectangle(frame, p1, p2, (255, 0, 0), 2, 1)
# Put FPS
cv2.putText(frame, "FPS : " + str(int(fps)), (100, 50), cv2.FONT_HERSHEY_SIMPLEX, 0.75, (50, 170, 50), 2)
cv2.imshow("Tracking", frame)
# Exit if ESC pressed
k = cv2.waitKey(1) & 0xff
if k == 27:
break
cam.release()
cv2.destroyAllWindows()
示例8: service_capture
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import getTickCount [as 别名]
def service_capture(self):
while(1):
t_start = cv2.getTickCount()
self.capture_mutex.acquire()
self.capture_state()
self.capture_image()
self.capture_mutex.release()
self.cost_time = ((cv2.getTickCount() - t_start) * 1000.0 / cv2.getTickFrequency())
# self.cost_time_vector.append(cost_time)
# self.state_vector.append(self.raw_state)
# print("Query raw_state cost time = %.2f" % cost_time)
# self.update["Get_data_cost_time": cost_time]
示例9: capture_state
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import getTickCount [as 别名]
def capture_state(self):
t_start = cv2.getTickCount()
self.state = self.client.getMultirotorState()
# self.collision_info = self.client.simGetCollisionInfo()
# print("Query raw_state cost time = %.2f" % ((cv2.getTickCount() - t_start) * 1000.0 / cv2.getTickFrequency()))
示例10: capture_image
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import getTickCount [as 别名]
def capture_image(self):
t_start = cv2.getTickCount()
responses = self.client.simGetImages([
airsim.ImageRequest("0", airsim.ImageType.DepthVis), # depth visualization image
airsim.ImageRequest("1", airsim.ImageType.DepthPerspective, True), # depth in perspective projection
airsim.ImageRequest("1", airsim.ImageType.Scene)]) # scene vision image in png format
# print('Retrieved images: %d', len(responses))
for response in responses:
if response.pixels_as_float:
self.img_f_raw = img_tools.process_float_img(response)
self.img_f = img_tools.float_img_to_display(self.img_f_raw)
# img_f = img_tools.displat_float_img( img_tools.process_float_img(response))
# cv2.imshow("img_float", img_tools.displat_float_img(img_f))
elif response.compress: # png format
self.img_png = img_tools.process_compress_img(response)
# cv2.imshow("img_png", img_png)
pass
else: # uncompressed array
self.img_rgba = img_tools.process_rgba_img(response)
# cv2.imshow("img_rgba", img_rgba)
try:
self.img_f = np.uint8(self.img_f)
self.img_f_rgb = cv2.cvtColor(self.img_f, cv2.COLOR_GRAY2RGB)
self.img_combi = np.concatenate((self.img_png, 255 - self.img_f_rgb), axis=0)
# print(vis.shape)
# cv2.imshow("image", self.img_combi)
except Exception as e:
print(e)
# print(img_f_rgb.shape, img_png.shape)
pass
# print("Query image cost time = %.2f" % ((cv2.getTickCount() - t_start) * 1000.0 / cv2.getTickFrequency()))
return self.img_combi
# cv2.waitKey(1)
示例11: replan
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import getTickCount [as 别名]
def replan(self):
print(colorize("===== Replan =====","red"))
self.move_to_pos([0,0,0])
if self.game_mode == "with_bias":
start_pos = self.current_pos
else:
start_pos = self.current_pos + self.pos_bias
start_pos = self.start_pos
# self.narrow_gap.approach_trajectory([0,0,0],
# [0,0,0],
# [0,0,0], if_draw=0)
# self.narrow_gap.approach_trajectory(start_pos,
# self.current_spd,
# self.current_acc, if_draw=0)
self.narrow_gap.approach_trajectory(start_pos,
[0,0,0],
[0,0,0], if_draw=0)
print("Start pos = ", start_pos)
self.narrow_gap.cross_ballistic_trajectory(if_draw=0);
self.approach_time = self.narrow_gap.Tf
self.cross_time = self.narrow_gap.t_c
final_target_rot = self.narrow_gap.get_rotation(self.approach_time + self.cross_time)
final_target_rot = self.transform_R_world_to_ned*final_target_rot
if (np.linalg.det(final_target_rot) == -1):
final_target_rot[:, 1] = final_target_rot[:, 1] * -1
self.final_rpy = transforms3d.euler.mat2euler( final_target_rot, axes = 'sxyz')
self.trajectory_start_t = cv2.getTickCount()
self.has_reach = 0
# Get observation
示例12: load_random_data
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import getTickCount [as 别名]
def load_random_data(save_dir, file_size):
sample_set = np.random.choice(range(0, file_size), file_size, replace=False)
sample_set = np.sort(sample_set)
# sample_set = range(file_size)
# print(random_set)
file_name_vec = []
for idx in sample_set:
name = "%s\\traj_%d.pkl" % (save_dir, idx)
file_name_vec.append(name)
rapid_trajectory = Rapid_trajectory_generator()
# t_start = cv2.getTickCount()
in_data, out_data = rapid_trajectory.load_from_file_vector(file_name_vec)
# print("cost time = %.2f " % ((cv2.getTickCount() - t_start) * 1000.0 / cv2.getTickFrequency()))
return in_data, out_data
示例13: start
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import getTickCount [as 别名]
def start(self):
self._accumulated = 0
self._start_time = cv2.getTickCount()
示例14: pause
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import getTickCount [as 别名]
def pause(self):
now_time = cv2.getTickCount()
self._accumulated += (now_time - self._start_time)/cv2.getTickFrequency()
self._is_paused = True
示例15: resume
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import getTickCount [as 别名]
def resume(self):
if self._is_paused: # considered only if paused
self._start_time = cv2.getTickCount()
self._is_paused = False