z80z80z80 / autocrop Goto Github PK
View Code? Open in Web Editor NEWAutomatically crop and rotate scanned images using OpenCV
License: GNU General Public License v3.0
Automatically crop and rotate scanned images using OpenCV
License: GNU General Public License v3.0
If a photo is really in diagonal, this function fails:
---------------------------------
| *tr
|
| * tl
|
| *br
|
| *bl
|
I propose the following code:
def order_rect(points):
# initialize result -> rectangle coordinates (4 corners, 2 coordinates (x,y))
res = np.zeros((4, 2), dtype=np.float32)
left_to_right = points[points[:, 0].argsort()] # Sorted by x
left_points = left_to_right[:2,:]
left_points = left_points[left_points[:, 1].argsort()] # Sorted by y
right_points = left_to_right[2:,:]
right_points = right_points[right_points[:, 1].argsort()] # Sorted by y
res[0] = left_points[0]
res[1] = right_points[0]
res[2] = right_points[1]
res[3] = left_points[1]
return res
Hey,
Thanks a lot for your this code!
I noted that one bracket is not being closed on line 114 currently:
Line 114 in abb6d7d
should be
print("WARNING: This seems to be an edge case. If the result isn't satisfying try lowering the threshold using -t")
Cheers.
These are questions before I start experimenting with this autocropping tool. It was not clear in the description on these items.
Does this work with RAW (Canon CR2) input files? Can the tool produce JPG and preferably TIFF output files on the cropped images?
How fast (cropped files per minute)?
Thanks for your help and time.
I am getting error in this line.
for f in files[0]:
IndexError: list index out of range
Hi,
I just stumbled uppon your very cool script:) Would it also be possible to cut black borders?
Which variables would have to be changed for this? I looked at the code but my python is to basic to fully understand it. I assume it would be somewhere in the cont
function?
I am digitizing old dias for my mother and they look as follows:
Thank your for your work done with this script, and I would be very happy to hear from you :)
Hi
I am trying to run the script, but it gives me an error:
python autocrop.py
File "autocrop.py", line 87
print(f"Adjust Threshold: {user_thresh}")
^
SyntaxError: invalid syntax
What could be the problem?
Found your script useful for a similar issue I'm running into for photo scans. It works well for me, but the file size increases significantly. E.g. uncropped, my images are 300-500kB but cropped they are about 1.5-2.5MB. Any idea why this is happening?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.