|
|
8장
classification, objection detection, segmentation 기술을 구분하여 자세히 설명하라
Classification (분류) : 데이터에 존재하는 객체의 종류를 분류하는 기술
Object Detection (객체 검출) : 데이터에 존재하는 객체의 종류와 위치를 동시에 구하는기술
Segmentation (분할) : 데이터에 존재하는 객체의 영역을 점 단위로 구분하는기술
2D object detection 모델은 크게 one-step 방식 two-step 방식의 모델 로나뉜다. 2가지 모델의차이를설명하고각경우모델의종류를조사 하라.
One-step 방식 : 한번에 바운딩 박스 위치와 클래스를 예측, 속도가 빠르지만 정확도가 상대적으로 낮음
- R-CNN
- Fast R-CNN
- Faster R-CNN
- Mask R-CNN
two-step 방식 : 후보영역을 생성하고 그 후부영역에 대해 정밀 조정하여 예측, 정확도가 높으나 느림.
- YOLO 시리즈
- RetinaNet
3D obeject detection 모델은 크게 point 기반모델과 voxel기반 모델로 나뉜다. 2가지 모델의 차이를 설명하고 각 경우 모델의 종류를 조사하 라.
Point 기반 모델 : 포인트 클라우드 데이터를 직접 처리하여 특징을 추출, 공간정보를 최대한 보존 가능함.
- PointNet
- PointNet++
- PointRCNN
Voxel 기반 모델 : 작은 정육면체로 나누어 각 voxel 단위로 특징을 추출.
이미지처럼 3D 격자 데이터로 변환해 3D CNN 적용 가능하지만 메모리 부담 큼.
- VoxelNet
- SECOND
- PointPillars
심층신경망이란무엇인가?
인간의 두뇌가 정보를 처리하는 방식(뉴런)을 모방한 머신러닝 모델, 여러 개의 은닉층을 가진 인공 신경망.
딥러닝이란무엇인가?
인공신경망을 기반으로 하는 머신러닝 기법의 한 종류로, 심층신경망을 이용해 데이터로부터 특징과 패턴을 자동으로 학습하는 모델
딥러닝라이브러리를조사하라.
TensorFlow, PyTorch, Keras ...
9장
1번
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | import open3d as o3d import numpy as np import cv2 file_path= 'C:/jsh/kitti/data_object_velodyne/training/velodyne/000000.bin' # (N, 4) 형식의numpyarray로변환, 행크기는알아서결정하고열크기는4개 points = np.fromfile(file_path, dtype=np.float32).reshape(-1, 4) print("배열크기:", points.shape) # 넘파이어레이크기출력 vis = o3d.visualization.Visualizer() vis.create_window(window_name='kitti',width=960, height=540) vis.get_render_option().point_size= 1.0 vis.get_render_option().background_color= np.zeros(3) # (0,0,0)->검정 axis_pcd= o3d.geometry.TriangleMesh.create_coordinate_frame(size=1.0, origin=[0, 0, 0]) vis.add_geometry(axis_pcd) dist = np.sqrt(points[:,0]**2 + points[:,1]**2 + points[:,2]**2) # 거리 계산 dist = dist <= 5.0 # 5.0 이하 true / 5.0 이상 false 인 배열 print("5m 이하 포인트 수:", np.sum(dist)) # 출력 dist_points = points[dist] # ture값만 사용 pcd= o3d.geometry.PointCloud()# 포인트클라우드객체생성 pcd.points= o3d.utility.Vector3dVector(dist_points[:, :3])# reflectance는제외 pcd.colors= o3d.utility.Vector3dVector(np.ones((dist_points.shape[0], 3)))# (1,1,1)->흰색 vis.add_geometry(pcd) # set zoom, front, up, and lookat vis.get_view_control().set_zoom(0.1) vis.get_view_control().set_front([0, -1, 1]) vis.get_view_control().set_lookat([0, 0, 0]) vis.get_view_control().set_up([0, 1, 1]) vis.run() vis.destroy_window() | cs |
2번
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | import open3d as o3d import numpy as np import cv2 file_path= 'C:/jsh/kitti/data_object_velodyne/training/velodyne/000000.bin' # (N, 4) 형식의numpyarray로변환, 행크기는알아서결정하고열크기는4개 points = np.fromfile(file_path, dtype=np.float32).reshape(-1, 4) print("배열크기:", points.shape) # 넘파이어레이크기출력 vis = o3d.visualization.Visualizer() vis.create_window(window_name='kitti',width=960, height=540) vis.get_render_option().point_size= 1.0 vis.get_render_option().background_color= np.zeros(3) # (0,0,0)->검정 axis_pcd= o3d.geometry.TriangleMesh.create_coordinate_frame(size=1.0, origin=[0, 0, 0]) vis.add_geometry(axis_pcd) dist = (points[:,2] <= -1.45) & (points[:,2] >= - 2. ) print("z -1.45 ~ -2 m 이하 포인트 수:", np.sum(dist)) # 출력 road_points = points[dist] # ture값만 사용 else_points = points[~dist] pcd= o3d.geometry.PointCloud()# 포인트클라우드객체생성 pcd.points= o3d.utility.Vector3dVector(else_points[:, :3])# reflectance는제외 pcd.colors= o3d.utility.Vector3dVector(np.ones((else_points.shape[0], 3)))# (1,1,1)->흰색 vis.add_geometry(pcd) # 2번 문제는 이 부분 제거 후 실행함 pcd_red= o3d.geometry.PointCloud()# 포인트클라우드객체생성 pcd_red.points= o3d.utility.Vector3dVector(road_points[:, :3])# reflectance는제외 red = np.zeros((road_points.shape[0], 3)) red[:, 0] = 1 pcd_red.colors= o3d.utility.Vector3dVector(red) vis.add_geometry(pcd_red) # set zoom, front, up, and lookat vis.get_view_control().set_zoom(0.1) vis.get_view_control().set_front([0, -1, 1]) vis.get_view_control().set_lookat([0, 0, 0]) vis.get_view_control().set_up([0, 1, 1]) vis.run() vis.destroy_window() | cs |
| 2번 | 3번 |
z : -1.45 ~ -2 부분이 도로라고 판단함.
4번
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | label_file_path = r"C:/jsh/kitti/data_object_label_2/training/label_2/005663.txt" labels = [] image_file_path= r"C:/jsh/kitti/data_object_image_2/training/image_2/005663.png" with open(label_file_path) as f: for line in f.readlines(): obj_label = line.strip().split() obj_type = obj_label[0] truncated = float(obj_label[1]) occluded = int(obj_label[2]) alpha = float(obj_label[3]) bbox = np.array(obj_label[4:8]).astype(float) dimension = np.array(obj_label[8:11]).astype(float) location = np.array(obj_label[11:14]).astype(float) location[1] -= dimension[0] / 2 # 중심 y 좌표 수정 rotation = float(obj_label[14]) # 딕셔너리 타입으로 저장 label = { 'type': obj_type, 'truncated': truncated, 'occluded': occluded, 'alpha': alpha, 'bbox': bbox, 'dimensions': dimension, 'location': location, 'rotation_y': rotation } labels.append(label) # 파싱 결과 출력 types = [] for data in labels: print( data['type'], data['truncated'], data['occluded'], data['alpha'], data['bbox'], data['dimensions'], data['location'], data['rotation_y'] ) types.append(data['type']) color_list = [ # 색깔 리스트 [255, 0, 0], [0, 255, 0], [0, 0, 255], [0, 255, 255], [255, 255, 0], [255, 0, 255], [0, 0, 0], [255, 255, 255], [128, 128, 128], [0, 165, 255], [128, 0, 128] ] types = set(types) # 중복 제거 types = list(types) print("종류 : ",types) image = cv2.imread(image_file_path) for data in labels: if data['type'] == 'DontCare':continue print(data['type'],data['truncated'],data['occluded'],data['alpha'],data['bbox'],data['dimensions'],data['location'],data['rotation_y']) data['bbox'] = list(map(int, data['bbox']))# 좌표를실수에서정수로변환 cv2.rectangle(image, data['bbox'][0:2], data['bbox'][2:4], color_list[types.index(data['type'])], 0) cv2.imshow('2d bbox', image) cv2.putText(image,data['type'],(data['bbox'][0], data['bbox'][1] - 5), cv2.FONT_HERSHEY_SIMPLEX,0.5,color_list[types.index(data['type'])]) cv2.waitKey() | cs |
