Exemplo n.º 1
0
import os
os.environ["OMP_NUM_THREADS"] = str(1)
import numpy as np
import cupoch as cph
cph.initialize_allocator(cph.PoolAllocation, 1000000000)
import open3d as o3d
import time


def measure_time(obj, method_name, device, *args):
    fn = getattr(obj, method_name)
    start = time.time()
    res = fn(*args)
    elapsed_time = time.time() - start
    print("%s (%s) [sec]:" % (method_name, device), elapsed_time)
    return res, elapsed_time


pinhole_camera_intrinsic_cpu = o3d.io.read_pinhole_camera_intrinsic(
    "../../testdata/camera_primesense.json")
source_color_cpu = o3d.io.read_image("../../testdata/rgbd/color/00000.jpg")
source_depth_cpu = o3d.io.read_image("../../testdata/rgbd/depth/00000.png")
target_color_cpu = o3d.io.read_image("../../testdata/rgbd/color/00001.jpg")
target_depth_cpu = o3d.io.read_image("../../testdata/rgbd/depth/00001.png")
print(source_color_cpu)
pinhole_camera_intrinsic_gpu = cph.io.read_pinhole_camera_intrinsic(
    "../../testdata/camera_primesense.json")
source_color_gpu = cph.io.read_image("../../testdata/rgbd/color/00000.jpg")
source_depth_gpu = cph.io.read_image("../../testdata/rgbd/depth/00000.png")
target_color_gpu = cph.io.read_image("../../testdata/rgbd/color/00001.jpg")
target_depth_gpu = cph.io.read_image("../../testdata/rgbd/depth/00001.png")
Exemplo n.º 2
0
import sys, os
import argparse
import pyrealsense2 as rs
import numpy as np
from enum import IntEnum
from ros_detect_planes_from_depth_img.plane_detector import test_PlaneDetector_send
import scipy.ndimage as nd
from read_bag import depth_filter

from datetime import datetime
import cupoch as x3d
x3d.initialize_allocator(x3d.PoolAllocation, 1000000000)


def get_intrinsic_matrix(frame):
    intrinsics = frame.profile.as_video_stream_profile().intrinsics
    out = x3d.camera.PinholeCameraIntrinsic(1280, 720, intrinsics.fx,
                                            intrinsics.fy, intrinsics.ppx,
                                            intrinsics.ppy)
    return out


def plane_detection(color_image, depth_array, loop=1):
    planes_mask, planes_normal, list_plane_params = test_PlaneDetector_send(\
            img_color=color_image, img_depth=depth_array)
    for idx in range(loop - 1):
        planes_mask_x, planes_normal_x, list_plane_params_x = test_PlaneDetector_send(\
            img_color=color_image, img_depth=depth_array)
        planes_mask += planes_mask_x
    planes_mask_binary = planes_mask
    r1, g1, b1 = 255, 0, 40  # Original value