嵌入式设备比如tx2的视觉

很棒的语义分割大全集
tx2可以用的网络
tx2官网
1、嵌入式语义分割ShuffleSeg
2、opencv车道线检测

import cv2
import utils
import matplotlib.pyplot as plt
import numpy as np



def processing(img,object_points,img_points,M,Minv):
    #camera calibration, image distortion correction 摄像机校准,图像失真校正
    undist = utils.cal_undistort(img,object_points,img_points)
    #get the thresholded binary image
    thresholded =utils.hls_select(undist, channel='s', thresh=(180, 255))
    # thresholded = thresholding(undist)
    #perform perspective  transform 执行透视变换
    thresholded_wraped = cv2.warpPerspective(thresholded, M, img.shape[1::-1], flags=cv2.INTER_LINEAR)
    left_fit, right_fit, left_lane_inds, right_lane_inds = utils.find_line(thresholded_wraped)

    # #perform detection 执行检测
    # if left_line.detected and right_line.detected:
    #     left_fit, right_fit, left_lane_inds, right_lane_inds = utils.find_line_by_previous(thresholded_wraped,left_line.current_fit,right_line.current_fit)
    # else:
    #
    # left_line.update(left_fit)
    # right_line.update(right_fit)

    #draw the detected laneline and the information
    area_img = utils.draw_area(undist,thresholded_wraped,Minv,left_fit, right_fit)
    curvature,pos_from_center = utils.calculate_curv_and_pos(thresholded_wraped,left_fit, right_fit)
    result = utils.draw_values(area_img,curvature,pos_from_center)

    return result

#获取棋盘格图片
cal_imgs = utils.get_images_by_dir('camera_cal')
object_points,img_points = utils.calibrate(cal_imgs,grid=(9,6))

#test_imgs = utils.get_images_by_dir('test_images')
test_imgs = utils.get_images_by_dir('new_test')



img=cv2.imread('./test_images/straight_lines1.jpg',1)
# 校正测试图片
dist = utils.cal_undistort(img, object_points, img_points)
# # cv2.imshow('fck1',org_img)
M, Minv = utils.get_M_Minv()
result = processing(img, object_points, img_points, M, Minv)

cv2.imshow('fck', result)
cv2.waitKey(0)

你可能感兴趣的:(tx2)