raspberry pi image cropping very slow
I am currently working on a project to capture and process photos on a
raspberry Pi. The photos are 6000X4000 about 2 mb, from a nikon D5200
camera. Everything is working fine, i have made a proof of concept in Java
and want to transform this to python or C depending on which language is
faster on the raspberry.
No the problem is that the images need to be cropped and re-sized, this
takes a very long time in the raspberry. In java the whole process of
reading the image, cropping and writing the new image takes about 2
minutes.
I have also tried ImageMagick but in command-line this even takes up to 3
minutes.
With a small python script i made this is reduces to 20 seconds, but this
is still a bit to long for my project.
Currently i am installing OpenCV to check if this is faster, this process
takes around 4 hours so i thought in the meantime i can ask a question
here.
Does anybody have any good idea's or libraries to speed up the process of
cropping and re-sizing the images.
Following is the python code i used
import Image
def crop_image(input_image, output_image, start_x, start_y, width, height):
"""Pass input name image, output name image, x coordinate to start
croping, y coordinate to start croping, width to crop, height to
crop """
input_img = Image.open(input_image)
box = (start_x, start_y, start_x + width, start_y + height)
output_img = input_img.crop(box)
output_img.save(output_image +".jpg")
def main():
crop_image("test.jpg","output", 1000, 0, 4000, 4000)
if __name__ == '__main__': main()
No comments:
Post a Comment