Skip to content

Commit

Permalink
Next release of imutils
Browse files Browse the repository at this point in the history
  • Loading branch information
jrosebr1 committed Feb 12, 2016
1 parent 4021028 commit ff1cc11
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
29 changes: 29 additions & 0 deletions demos/temp_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# author: Adrian Rosebrock
# website: http://www.pyimagesearch.com

# USAGE
# BE SURE TO INSTALL 'imutils' PRIOR TO EXECUTING THIS COMMAND
# python temp_file.py --image ../demo_images/bridge.jpg

# import the necessary packages
from __future__ import print_function
from imutils.io import TempFile
import argparse
import cv2

# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True, help="path to input image")
args = ap.parse_args()

# load the input image
image = cv2.imread(args.image)

# create a temporary path for the image, then write the image
# to file
t = TempFile()
cv2.imwrite(t.path, image)
print("[INFO] path: {}".format(t.path))

# delete the file
t.cleanup()
2 changes: 2 additions & 0 deletions imutils/io/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# import the necessary packages
from .tempfile import TempFile
13 changes: 13 additions & 0 deletions imutils/io/tempfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# import the necessary packages
import uuid
import os

class TempFile:
def __init__(self, basePath="./", ext=".jpg"):
# construct the file path
self.path = "{base_path}/{rand}{ext}".format(base_path=basePath, rand=str(uuid.uuid4()),
ext=ext)

def cleanup(self):
# remove the file
os.remove(self.path)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='imutils',
packages=['imutils', 'imutils.video'],
packages=['imutils', 'imutils.video', 'imutils.io'],
version='0.3.4',
description='A series of convenience functions to make basic image processing functions such as translation, rotation, resizing, skeletonization, displaying Matplotlib images, sorting contours, detecting edges, and much more easier with OpenCV and both Python 2.7 and Python 3.',
author='Adrian Rosebrock',
Expand Down

0 comments on commit ff1cc11

Please sign in to comment.