bashubuntucomputer-visioncoredumpasift

execute a command on all images of all sub folders in bash


I have a code for ubuntu that extracts hessian-affine descriptors in an image. its an executable file named haff_cvpr09, it gets an image name for input in "haff_cvpr09 imageName.ppm" format and gives a result out. I can execute it on one image in '.\haff_cvpr09 imageNmae.ppm' command format in terminal, and it works well, but now I have 5000 images in 17 folders, I wanted to run that code on all images, then i tried

for file in 'folder path*.ppm'; do .\haff_cvpr09 $file; done

but I got segmentation fault(core dumped) error! I wanted to know how I can do this in terminal or bash in UBUNTU.

any help is appreciated: )


Solution

  • The samples way is to use something like:

    find <folder> -type f -name "*.ppm" -exec ./haff_cvpr09 {} \;
    

    Be aware this may not work if you have files with whitespace in the name

    Replace <folder> with you folder name