UPDATE Vision 修复深度图对齐彩色图
This commit is contained in:
@ -15,7 +15,8 @@ import time
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from Vision.tool.CameraRVC import camera_rvc
|
from Vision.tool.CameraRVC import camera_rvc
|
||||||
from Vision.tool.CameraPe_color2depth import camera_pe
|
from Vision.tool.CameraPe_color2depth import camera_pe as camera_pe_color2depth
|
||||||
|
from Vision.tool.CameraPe_depth2color import camera_pe as camera_pe_depth2color
|
||||||
from Vision.yolo.yolov8_pt_seg import yolov8_segment
|
from Vision.yolo.yolov8_pt_seg import yolov8_segment
|
||||||
from Vision.yolo.yolov8_openvino import yolov8_segment_openvino
|
from Vision.yolo.yolov8_openvino import yolov8_segment_openvino
|
||||||
from Vision.tool.utils import find_position
|
from Vision.tool.utils import find_position
|
||||||
@ -28,15 +29,17 @@ from Vision.tool.utils import uv_to_XY
|
|||||||
|
|
||||||
class Detection:
|
class Detection:
|
||||||
|
|
||||||
def __init__(self, use_openvino_model=False, cameraType = 'Pe'): # cameraType = 'RVC' or cameraType = 'Pe'
|
def __init__(self, use_openvino_model=False, cameraType = 'Pe', alignmentType = 'color2depth'): # cameraType = 'RVC' or cameraType = 'Pe'
|
||||||
"""
|
"""
|
||||||
初始化相机及模型
|
初始化相机及模型
|
||||||
:param use_openvino_model: 选择模型,默认使用openvino
|
:param use_openvino_model: 选择模型,默认使用openvino
|
||||||
:param cameraType: 选择相机 如本相机 'RVC', 图漾相机 'Pe'
|
:param cameraType: 选择相机 如本相机 'RVC', 图漾相机 'Pe'
|
||||||
|
:param alignmentType: 相机对齐方式 color2depth:彩色图对齐深度图 ;depth2color:深度图对齐彩色图
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.use_openvino_model = use_openvino_model
|
self.use_openvino_model = use_openvino_model
|
||||||
self.cameraType = cameraType
|
self.cameraType = cameraType
|
||||||
|
self.alignmentType= alignmentType
|
||||||
if self.use_openvino_model == False:
|
if self.use_openvino_model == False:
|
||||||
model_path = ''.join([os.getcwd(), '/Vision/model/pt/one_bag.pt'])
|
model_path = ''.join([os.getcwd(), '/Vision/model/pt/one_bag.pt'])
|
||||||
device = 'cpu'
|
device = 'cpu'
|
||||||
@ -44,7 +47,10 @@ class Detection:
|
|||||||
self.camera_rvc = camera_rvc()
|
self.camera_rvc = camera_rvc()
|
||||||
self.seg_distance_threshold = 10 # 1厘米
|
self.seg_distance_threshold = 10 # 1厘米
|
||||||
elif self.cameraType == 'Pe':
|
elif self.cameraType == 'Pe':
|
||||||
self.camera_rvc = camera_pe()
|
if self.alignmentType=='color2depth':
|
||||||
|
self.camera_rvc = camera_pe_color2depth()
|
||||||
|
else:
|
||||||
|
self.camera_rvc = camera_pe_depth2color()
|
||||||
self.seg_distance_threshold = 15 # 2厘米
|
self.seg_distance_threshold = 15 # 2厘米
|
||||||
else:
|
else:
|
||||||
print('相机参数错误')
|
print('相机参数错误')
|
||||||
@ -58,7 +64,10 @@ class Detection:
|
|||||||
self.camera_rvc = camera_rvc()
|
self.camera_rvc = camera_rvc()
|
||||||
self.seg_distance_threshold = 10
|
self.seg_distance_threshold = 10
|
||||||
elif self.cameraType == 'Pe':
|
elif self.cameraType == 'Pe':
|
||||||
self.camera_rvc = camera_pe()
|
if self.alignmentType == 'color2depth':
|
||||||
|
self.camera_rvc = camera_pe_color2depth()
|
||||||
|
else:
|
||||||
|
self.camera_rvc = camera_pe_depth2color()
|
||||||
self.seg_distance_threshold = 20
|
self.seg_distance_threshold = 20
|
||||||
else:
|
else:
|
||||||
print('相机参数错误')
|
print('相机参数错误')
|
||||||
|
|||||||
@ -124,7 +124,7 @@ class camera_pe():
|
|||||||
:return: ret , img, point_map
|
:return: ret , img, point_map
|
||||||
'''
|
'''
|
||||||
if self.caminit_isok == False or self.event.IsOffline():
|
if self.caminit_isok == False or self.event.IsOffline():
|
||||||
return 0, None, None
|
return 0, None, None, None
|
||||||
else:
|
else:
|
||||||
image_list = self.cl.DeviceStreamRead(self.handle, 2000)
|
image_list = self.cl.DeviceStreamRead(self.handle, 2000)
|
||||||
if len(image_list) == 2:
|
if len(image_list) == 2:
|
||||||
|
|||||||
@ -80,6 +80,7 @@ class camera_pe():
|
|||||||
# print('\t{} -size[{}x{}]\t-\t desc:{}'.format(idx, cl.Width(fmt), cl.Height(fmt), fmt.getDesc()))
|
# print('\t{} -size[{}x{}]\t-\t desc:{}'.format(idx, cl.Width(fmt), cl.Height(fmt), fmt.getDesc()))
|
||||||
self.cl.DeviceStreamFormatConfig(self.handle, PERCIPIO_STREAM_DEPTH, depth_fmt_list[2]) # 深度图大小
|
self.cl.DeviceStreamFormatConfig(self.handle, PERCIPIO_STREAM_DEPTH, depth_fmt_list[2]) # 深度图大小
|
||||||
self.depth_calib_data = self.cl.DeviceReadCalibData(self.handle, PERCIPIO_STREAM_DEPTH)
|
self.depth_calib_data = self.cl.DeviceReadCalibData(self.handle, PERCIPIO_STREAM_DEPTH)
|
||||||
|
self.color_calib_data = self.cl.DeviceReadCalibData(self.handle, PERCIPIO_STREAM_COLOR)
|
||||||
|
|
||||||
err = self.cl.DeviceLoadDefaultParameters(self.handle)
|
err = self.cl.DeviceLoadDefaultParameters(self.handle)
|
||||||
if err:
|
if err:
|
||||||
@ -124,7 +125,7 @@ class camera_pe():
|
|||||||
:return: ret , img, point_map
|
:return: ret , img, point_map
|
||||||
'''
|
'''
|
||||||
if self.caminit_isok == False or self.event.IsOffline():
|
if self.caminit_isok == False or self.event.IsOffline():
|
||||||
return 0, None, None
|
return 0, None, None, None
|
||||||
else:
|
else:
|
||||||
image_list = self.cl.DeviceStreamRead(self.handle, 2000)
|
image_list = self.cl.DeviceStreamRead(self.handle, 2000)
|
||||||
if len(image_list) == 2:
|
if len(image_list) == 2:
|
||||||
@ -140,7 +141,7 @@ class camera_pe():
|
|||||||
|
|
||||||
self.cl.DeviceStreamDepthRender(self.img_registration_depth, self.img_registration_render)
|
self.cl.DeviceStreamDepthRender(self.img_registration_depth, self.img_registration_render)
|
||||||
mat_depth_render = self.img_registration_render.as_nparray()
|
mat_depth_render = self.img_registration_render.as_nparray()
|
||||||
self.cl.DeviceStreamMapDepthImageToPoint3D(self.img_registration_depth, self.depth_calib_data, self.scale_unit,
|
self.cl.DeviceStreamMapDepthImageToPoint3D(self.img_registration_depth, self.color_calib_data, self.scale_unit,
|
||||||
self.pointcloud_data_arr)
|
self.pointcloud_data_arr)
|
||||||
p3d_nparray = self.pointcloud_data_arr.as_nparray()
|
p3d_nparray = self.pointcloud_data_arr.as_nparray()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user