def main():
    # Create a PyZEDCamera object
    zed = zcam.PyZEDCamera()

    # Create a PyInitParameters object and set configuration parameters
    init_params = zcam.PyInitParameters()
    init_params.camera_resolution = sl.PyRESOLUTION.PyRESOLUTION_HD720  # Use HD720 video mode (default fps: 60)
    # Use a right-handed Y-up coordinate system
    init_params.coordinate_system = sl.PyCOORDINATE_SYSTEM.PyCOORDINATE_SYSTEM_RIGHT_HANDED_Y_UP
    init_params.coordinate_units = sl.PyUNIT.PyUNIT_METER  # Set units in meters

    # Open the camera
    err = zed.open(init_params)
    if err != tp.PyERROR_CODE.PySUCCESS:
        exit(1)

    # Enable positional tracking with default parameters.
    # Positional tracking needs to be enabled before using spatial mapping
    py_transform = core.PyTransform()
    tracking_parameters = zcam.PyTrackingParameters(init_pos=py_transform)
    err = zed.enable_tracking(tracking_parameters)
    if err != tp.PyERROR_CODE.PySUCCESS:
        exit(1)

    # Enable spatial mapping
    mapping_parameters = zcam.PySpatialMappingParameters()
    err = zed.enable_spatial_mapping(mapping_parameters)
    if err != tp.PyERROR_CODE.PySUCCESS:
        exit(1)

    # Grab data during 500 frames
    i = 0
    py_mesh = mesh.PyMesh()  # Create a PyMesh object

    while i < 500:
        # For each new grab, mesh data is updated
        if zed.grab(zcam.PyRuntimeParameters()) == tp.PyERROR_CODE.PySUCCESS:
            # In the background, spatial mapping will use newly retrieved images, depth and pose to update the mesh
            mapping_state = zed.get_spatial_mapping_state()

            print("\rImages captured: {0} / 500 || {1}".format(
                i, mapping_state))

            i = i + 1

    print("\n")

    # Extract, filter and save the mesh in an obj file
    print("Extracting Mesh...\n")
    zed.extract_whole_mesh(py_mesh)
    print("Filtering Mesh...\n")
    py_mesh.filter(mesh.PyMeshFilterParameters()
                   )  # Filter the mesh (remove unnecessary vertices and faces)
    print("Saving Mesh...\n")
    py_mesh.save("mesh.obj")

    # Disable tracking and mapping and close the camera
    zed.disable_spatial_mapping()
    zed.disable_tracking()
    zed.close()
def main():

    if len(sys.argv) != 2:
        print("Please specify path to .svo file.")
        exit()

    filepath = sys.argv[1]
    print("Reading SVO file: {0}".format(filepath))

    cam = zcam.PyZEDCamera()
    init = zcam.PyInitParameters(svo_input_filename=filepath)
    status = cam.open(init)
    if status != tp.PyERROR_CODE.PySUCCESS:
        print(repr(status))
        exit()

    runtime = zcam.PyRuntimeParameters()
    spatial = zcam.PySpatialMappingParameters()
    transform = core.PyTransform()
    tracking = zcam.PyTrackingParameters(transform)

    cam.enable_tracking(tracking)
    cam.enable_spatial_mapping(spatial)

    pymesh = mesh.PyMesh()
    print("Processing...")
    for i in range(200):
        cam.grab(runtime)
        cam.request_mesh_async()

    cam.extract_whole_mesh(pymesh)
    cam.disable_tracking()
    cam.disable_spatial_mapping()

    filter_params = mesh.PyMeshFilterParameters()
    filter_params.set(mesh.PyFILTER.PyFILTER_HIGH)
    print("Filtering params : {0}.".format(pymesh.filter(filter_params)))

    apply_texture = pymesh.apply_texture(
        mesh.PyMESH_TEXTURE_FORMAT.PyMESH_TEXTURE_RGBA)
    print("Applying texture : {0}.".format(apply_texture))
    print_mesh_information(pymesh, apply_texture)

    save_filter(filter_params)
    save_mesh(pymesh)
    cam.close()
    print("\nFINISH")
Пример #3
0
		pipeline.process(frame)
		print pipeline.boundingRects
		print pipeline.center

    # Press Q on keyboard to  exit
	if cv2.waitKey(25) & 0xFF == ord('q'):
		break
 
   #Break the loop
	else: 
		break
"""
print("============Vision Active=============")
while streamRunning:
    if temp == 30:
        mapping_parameters = zcam.PySpatialMappingParameters()
        err = cam.enable_spatial_mapping(mapping_parameters)
        if err != tp.PyERROR_CODE.PySUCCESS:
            print("Spatial Mapping Failed")
            failed = 1
        if err == tp.PyERROR_CODE.PySUCCESS:
            print("Spatial Mapping Initalized")
            failed = 0
    if failed == 1:
        mapping_parameters = zcam.PySpatialMappingParameters()
        err = cam.enable_spatial_mapping(mapping_parameters)
        if err != tp.PyERROR_CODE.PySUCCESS:
            print("Spatial Mapping Failed")
            failed = 1
        if err == tp.PyERROR_CODE.PySUCCESS:
            print("Spatial Mapping Initalized")