Hyperion Hyperion - 7 months ago 26
Python Question

Python modules lib.util and lib.geom

I'm using this code to crop some images, but I always get error:

ImportError: No module named lib.util


same for lib.geom. How can I install these modules? I've tried searching on Google but I didn't find anything.

Answer

Because those functions were likely made by the author. Check the following links:

sort_coords

# Sorts an array of 4 coordinates, each an array w/ 2 numbers
#  into counter-clockwise order starting from top left

skew

# expects two points vertically separated. If your points are horizontally
#  separated, reverse their x and y when passing into this function
#  output is the angle between the line the two points make and the horizontal

I'm just linking to the same code the author did in his blog.

EDIT: As suggested by @Francesco, you can use the code in those helper functions in many possible ways. Either you copy the functions into your script file and use them directly without import, or you just build modules (or a package) as the author did.

Personally for such a small number of functions I would go with the first way. It's faster and everything remains on the same script file.