コード例 #1
0
 def _load_patch(self, data, datalist):
     batch_patch = []
     for k, im in enumerate(data):
         filename_img = datalist[k][0]
         path, name, ext = fp.fileparts(filename_img)
         filename_pts = os.path.join(path, name + '.pts')
         pts = utils.read_pts(filename_pts)
         rois = utils.get_rois(im, pts, 0.2, 0.15,
                               self.roi_size)  # 224x224x25
         batch_patch.append(rois)
     return np.array(batch_patch)
コード例 #2
0
ファイル: main.py プロジェクト: XrosLiang/point2mesh
from options import Options
import time
import os

options = Options()
opts = options.args

torch.manual_seed(opts.torch_seed)
device = torch.device('cuda:{}'.format(opts.gpu) if torch.cuda.is_available() else torch.device('cpu'))
print('device: {}'.format(device))

# initial mesh
mesh = Mesh(opts.initial_mesh, device=device, hold_history=True)

# input point cloud
input_xyz, input_normals = utils.read_pts(opts.input_pc)
# normalize point cloud based on initial mesh
input_xyz /= mesh.scale
input_xyz += mesh.translations[None, :]
input_xyz = torch.Tensor(input_xyz).type(options.dtype()).to(device)[None, :, :]
input_normals = torch.Tensor(input_normals).type(options.dtype()).to(device)[None, :, :]

part_mesh = PartMesh(mesh, num_parts=options.get_num_parts(len(mesh.faces)), bfs_depth=opts.overlap)
print(f'number of parts {part_mesh.n_submeshes}')
net, optimizer, rand_verts, scheduler = init_net(mesh, part_mesh, device, opts)

for i in range(opts.iterations):
    num_samples = options.get_num_samples(i % opts.upsamp)
    if opts.global_step:
        optimizer.zero_grad()
    start_time = time.time()
コード例 #3
0
#
#
#all_optical_pts = []
#
#for i in range(len(optical_pts_list)):
#    all_optical_pts = [*all_optical_pts, *optical_pts_list[i]]
#
#print(len(all_optical_pts))

#REPROJECTION ERROR (RET)
ret = np.load('./camera_params_thermal/ret.npy')

im = cv2.imread('camera_calibration/Fakkel_DD/DJI_0651.JPG')

#DD points
optical_pts = read_pts(
    './camera_calibration/Fakkel_DD/optical_key_pts_fakkel_DD.txt')
thermal_pts = read_pts(
    './camera_calibration/Fakkel_DD/thermal_key_pts_fakkel_DD.txt')
thermal_pts_undist = list(map(lambda p: undistort_pts(p), thermal_pts))
thermal_pts_undist_trans = list(
    map(lambda p: transform_pts(p), thermal_pts_undist))

x_t = thermal_pts_undist_trans[0][:, 0]
y_t = thermal_pts_undist_trans[0][:, 1]
x_o = optical_pts[0][:, 0]
y_o = optical_pts[0][:, 1]

plt.figure(figsize=(8, 6))
plt.imshow(im, alpha=0.5)
plt.scatter(x_t, y_t, marker='+', label='visual')
plt.scatter(x_o, y_o, marker='+', label='infrared')
コード例 #4
0
# termination criteria
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)

# prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(6,5,0)
objp = np.zeros((6 * 9, 3), np.float32)
objp[:, :2] = np.mgrid[0:9, 0:6].T.reshape(-1, 2)

# Arrays to store object points and image points from all the images.
objpoints = []  # 3d point in real world space
imgpoints = []  # 2d points in image plane.

images = glob.glob('./camera_calibration/00_allThermal/*.jpg')
#images_optical = glob.glob('camera_calibration/Optical_and_thermal/optical/*.jpg')
#corners_optical = read_pts('Newest_data/Old2/optical_key_pts_check2.txt')
corners_thermal = read_pts(
    './camera_calibration/00_allThermal/00_corner_coords.txt')

###VISUALIZE
#i = 0
#plt.figure(figsize=(20,40))
#plt.subplots_adjust(wspace=.1, hspace=.1)
#Rows = math.ceil(len(images)/6)
#
#for fname in images:
#
#    img = cv2.imread(fname)
#    gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
#    corners = corners_thermal[i]
#
#    for j in range(corners.shape[0]):
#        cv2.circle(img,(int(corners[j,0]),int(corners[j,1])),4,(255,0,0),-1)
コード例 #5
0
#
####TRANSFORM IR_im TO VIS COORD SYSTEM
#im = cv2.imread('00_Alignment/camera_calibration/test/DJI_0692.JPG')
#imv = cv2.imread('00_Alignment/camera_calibration/test/DJI_0691.JPG')
#
##plt.figure()
##plt.imshow(imv)
#
##plt.figure()
##plt.imshow(transform_IR_im_to_vis_coordinate_system(im))
##plt.imshow(get_line_mask(imv))
##
#####TRANSFORM IR pts
#IR_pts = read_pts('./00_Alignment/camera_calibration/Fakkel_DD/thermal_key_pts_fakkel_DD.txt')[0]
Vis_pts = read_pts(
    './00_Alignment/camera_calibration/Fakkel_DD/optical_key_pts_fakkel_DD.txt'
)[0]
#
##tformed_pts = transform_IR_pt_list_to_vis_coordinate_system(IR_pts)
##plt.figure()
##plt.scatter(tformed_pts[:,0], tformed_pts[:,1],  marker='+', label='infrared' )
##plt.scatter(Vis_pts[:,0], Vis_pts[:,1],  marker='+', label='visual' )
#
##TRANSFORM VIS IM TO IR COORD SYSTEM:
#plt.figure()
#plt.imshow(im)
#
#imv_t = transform_vis_im_to_IR_coordinate_system(imv)
#print(np.max(imv_t))
#imv_t = np.array(imv_t*255, np.uint8)
#print(imv_t.shape)