- http://sourceforge.net/apps/mediawiki/pyvision/index.php?title=Quick_Start_1
- http://www.opencv.org.cn/index.php/Canny边缘检测2
The second Python example works on my MacBook. So HighGUI does work on the Mac OS X.
Open Source, Embedded Systems, Computer Vision, Computational Photography, Self-Improvement
#!/usr/bin/env python
import sys
import Image
# Loop through all provided arguments
for i in range(1, len(sys.argv)):
try:
# Attempt to open an image file
filepath = sys.argv[i]
image = Image.open(filepath)
except IOError, e:
# Report error, and then skip to the next argument
print "Problem opening", filepath, ":", e
continue
# Perform operations on the image here
$ batch_process.py image.gif
$ batch_process.py image1.png image2.gif image3.jpg
$ batch_process.py *.png
$ batch_process.py image1.gif, *.png
#Resize an image
image = image.resize((width, height), Image.ANTIALIAS)
# Convert to greyscale
image = image.convert('L')
# Blur
image = image.filter(ImageFilter.BLUR)
# Sharpen
image = image.filter(ImageFilter.SHARPEN)
# Split our original filename into name and extension
(name, extension) = os.path.splitext(filepath)
# Save with "_changed" added to the filename
image.save(name + '_changed' + extension)
# Save the image as a JPG
image.save(name + '.jpg')
!/usr/bin/env python
# Batch thumbnail generation script using PIL
import sys
import os.path
import Image
thumbnail_size = (28, 28)
# Loop through all provided arguments
for i in range(1, len(sys.argv)):
try:
# Attempt to open an image file
filepath = sys.argv[i]
image = Image.open(filepath)
except IOError, e:
# Report error, and then skip to the next argument
print "Problem opening", filepath, ":", e
continue
# Resize the image
image = image.resize(thumbnail_size, Image.ANTIALIAS)
# Split our original filename into name and extension
(name, extension) = os.path.splitext(filepath)
# Save the thumbnail as "(original_name)_thumb.png"
image.save(name + '_thumb.png')
exiftool "-AllDates-=1:: 0" *.jpg