Skip to content

Instantly share code, notes, and snippets.

@bsridatta
Last active May 22, 2024 15:51
Show Gist options
  • Save bsridatta/e1e0964b5c6b424549c12d8c4156bb4b to your computer and use it in GitHub Desktop.
Save bsridatta/e1e0964b5c6b424549c12d8c4156bb4b to your computer and use it in GitHub Desktop.
Script to convert multiple PCD files into other formats using PCL
"""
Script to convert multiple PCD files into other formats using PCL
"""
import os
import subprocess
__author__ = "Sri Datta Budaraju"
# Make sure you have PCL installed
package = 'pcl_convert_pcd_ascii_binary'
input_dir = 'home/inputPCD/'
output_dir = 'home/formattedPCD/'
# Available conversion formats
asciiFormat = '0'
binaryFormat = '1'
binaryCompressedFormat = '2'
# Choosing binaryCompressedFormat
formatChoice = binaryCompressedFormat
for pcd in os.listdir(input_dir):
# convert all PCD in input directory
print('Converting pcd :', pcd)
inputPCD = input_dir + '/' + pcd
outputPCD = output_dir + '/' + 'binComp.bin'
# PCL command
command = [package,
inputPCD,
outputPCD,
formatChoice]
subprocess.call(command)
break
os.remove(inputPCD)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment