I want to do a segmentation and then generate a point cloud. Now I read the color image and depth image saved by the program, and then input the program to generate the point cloud, but found that the program cannot run normally.
the code as follows:
import cv2
import numpy as np
from ultralytics import YOLO
import open3d as o3d
from pykinect2 import PyKinectV2
from pykinect2 import PyKinectRuntime
I want to do a segmentation and then generate a point cloud. Now I read the color image and depth image saved by the program, and then input the program to generate the point cloud, but found that the program cannot run normally. the code as follows:
import cv2 import numpy as np from ultralytics import YOLO
import open3d as o3d from pykinect2 import PyKinectV2 from pykinect2 import PyKinectRuntime
import code,os,struct import ctypes,_ctypes
初始化Kinect传感器
kinect = PyKinectRuntime.PyKinectRuntime(PyKinectV2.FrameSourceTypes_Depth)
def addchanel(color,alpha_value=0): h,w = color.shape[:2] a_channel=np.full((h,w),alpha_value,dtype=color.dtype) brg_img=cv2.merge((color,a_channel)) return brg_img
def rgb2float(self, r, g, b, a=0): return struct.unpack('f', struct.pack('i', r << 16 | g << 8 | b))[0] def point_cloud(depth_frame, color_frame, Float_RGB_type): print(color_frame.shape) print(depth_frame.shape)
size must be what the kinect offers as depth frame
if name == 'main':
the picture as follow: