UPDATE Vision 保存图片和点云
This commit is contained in:
@ -16,11 +16,13 @@ from Vision.yolo.yolov8_pt_seg import yolov8_segment
|
||||
from Vision.yolo.yolov8_openvino import yolov8_segment_openvino
|
||||
from Vision.tool.utils import find_position
|
||||
from Vision.tool.utils import class_names
|
||||
from Vision.tool.utils import get_disk_space
|
||||
import time
|
||||
import os
|
||||
|
||||
class Detection:
|
||||
|
||||
def __init__(self, use_openvino_model = True):
|
||||
def __init__(self, use_openvino_model=True):
|
||||
self.use_openvino_model = use_openvino_model
|
||||
if self.use_openvino_model==False:
|
||||
model_path = ''.join([os.getcwd(), '/Vision/model/pt/best.pt'])
|
||||
@ -36,7 +38,7 @@ class Detection:
|
||||
|
||||
|
||||
|
||||
def get_position(self, Point_isVision=False):
|
||||
def get_position(self, Point_isVision=False, save_img_piont=True):
|
||||
""
|
||||
'''
|
||||
:param api: None
|
||||
@ -45,6 +47,22 @@ class Detection:
|
||||
ret, img, pm = self.camera_rvc.get_img_and_point_map() # 拍照,获取图像及
|
||||
if self.camera_rvc.caminit_isok == True:
|
||||
if ret == 1:
|
||||
if save_img_piont == True:
|
||||
if get_disk_space(path=os.getcwd()) < 15: # 内存小于15G,停止保存数据
|
||||
save_img_piont = False
|
||||
print('系统内存不足,无法保存数据')
|
||||
else:
|
||||
save_path = ''.join([os.getcwd(), '/Vision/model/data/',
|
||||
time.strftime('%Y_%m_%d_%H_%M_%S', time.localtime(time.time()))])
|
||||
save_img_name = ''.join([save_path, '.png'])
|
||||
save_piont_name = ''.join([save_path, '.xyz'])
|
||||
row_list = list(range(1, 1080, 2))
|
||||
column_list = list(range(1, 1440, 2))
|
||||
pm_save = pm.copy()
|
||||
pm_save1 = np.delete(pm_save, row_list, axis=0)
|
||||
point_new = np.delete(pm_save1, column_list, axis=1)
|
||||
point_new = point_new.reshape(-1, 3)
|
||||
np.savetxt(save_piont_name, point_new)
|
||||
if self.use_openvino_model == False:
|
||||
flag, det_cpu, dst_img, masks, category_names = self.model.model_inference(img, 0)
|
||||
else:
|
||||
@ -196,9 +214,14 @@ class Detection:
|
||||
outlier_cloud = pcd.select_by_index(inliers, invert=True)
|
||||
outlier_cloud.paint_uniform_color([0, 1, 0])
|
||||
o3d.visualization.draw_geometries([inlier_cloud, outlier_cloud, pcd2])
|
||||
|
||||
if save_img_piont == True:
|
||||
save_img = cv2.resize(img, (720, 540))
|
||||
cv2.imwrite(save_img_name, save_img)
|
||||
return 1, img, xyz[_idx], nx_ny_nz[_idx]
|
||||
else:
|
||||
if save_img_piont == True:
|
||||
save_img = cv2.resize(img,(720, 540))
|
||||
cv2.imwrite(save_img_name, save_img)
|
||||
return 1, img, None, None
|
||||
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user