Doing sophisticated image analysis with python / django - django

I am working on a django project that analyzes images that contain text and (1) infers if the image needs to be rotated and (2) where text areas are.
I am currently using PIL to do some more simpler processing of these images but I am not quite sure how I can use PIL or other libraries to perform both tasks. I was wondering if anyone has done this before and if there are libraries / api available to help in the development.

OpenCV is probably the post popular open source image processing library. It's C/C++ but there are python bindings:
http://opencv.willowgarage.com/wiki/
and the python docs
http://opencv.willowgarage.com/documentation/python/index.html
I've never done an OCR with it, but I'm sure it's capable

I agree with #pastylegs that OpenCV is your best initial bet. If you need stuff specific to OCR you could also look at ocropus.

Related

How do i go about developing a facial identification software that identify different users and show their name from an image database using C++

I'm trying to develop a facial recognition software that holds a database of different images and uses the camera to identify each person and shows their name on screen. I'm more familiar with using C++ and I assume python might be the best language to get the job done but I want to know how I can go about it with C++. what algorithm do I have to use and a break down of how I can do it. thank you (:
OpenCV must be installed on the local machine.
Paths to the classifier XML files must be given before the execution of the program. These XML files can be found in the OpenCV directory “opencv/data/haarcascades”.
Use 0 in capture.open(0) to play webcam feed.
For detection in a local video provide the path to the video.(capture.open(“path_to_video”)).
You can get in-depth knowledge here
Tutorial

How to apply wavelet filter to MRI nifti images?

I need to denoise nifti images using wavelet transform. I did it in MATLAB but I should write the code for my project in Python. I am new to Python.
Python has a neuroimaging community of practice that lives at http://nipy.org. In particular, they have a library called NiBabel (see their introduction and github) for reading nifti and other formats (this will replace MATLAB's niftiread). You may also be interested in the PyWavelets library, which can replace basic parts of the MATLAB wavelet toolbox. The Pillow library is probably the most up to date image editing/processing library for Python, but as far as I'm aware wavelets isn't something covered there.
Is that enough to get you started? A basic discussion of how Python packages work seems beyond the scope of this question, but you can do some reading at https://pypi.org/help/ if you are completely lost.

c++ video compression library that supports many different compression algorithms?

For a scientific project i need to compress video data. The video however doesn't contain natural video and the quality characteristics of the compression will be different than for natural footage (preservation of hard edges for example is more important than smooth gradients or color correctness).
I'm looking for a library that can be easily integrated in an existing c++ project and that let's me experiment with different video compression algorithms.
Any suggestions?
Look at FFmpeg. It is the the most mature open source tool for video compression and decompression. It comes with a command line tool, and with libraries for codecs and muxers/demuxers that can be statically or dynamically linked.
As satuon already answered, FFmpeg is the go-to solution for all things multimedia. However, I just wanted to suggest an easier path for you than trying to hook your program up to its libraries. It would probably be far easier for you to generate a sequence of raw RGB images within your program, dump each out to disc (perhaps using a ridiculously simple format like PPM), and then use FFmpeg from the command like to compress them into a proper movie.
This workflow might cut down on your prototyping and development time.
As for the specific video codec you will want to use, you have a plethora of options available to you. One of the most important considerations will be: Who needs to be able to play your video and what software will they have available?

How to verify the integrity of a image file in c++ or python?

I want to check whether the images is downloaded completely. Is there any library to use?
The images I want to verify including various formats such jpeg, png, bmp etc.
The standard go-to library for that kind of thing in Python is the Python Imaging Library (PIL).
I have used Pyhton Pillow module (PIL) and Imagemagick wrapper wand (for psd, xcf formats) in order to detect broken images, the original answer with code snippets is here.
I also implemented this solution in my Python script here on GitHub.
I also verified that damaged files (jpg) frequently are not 'broken' images i.e, a damaged picture file sometimes remains a legit picture file, the original image is lost or altered but you are still able to load it.
I quote the full answer for completeness:
You can use Python Pillow(PIL) module, with most image formats, to check if a file is a valid and intact image file.
In the case you aim at detecting also broken images, #Nadia Alramli correctly suggests the im.verify() method, but this does not detect all the possible image defects, e.g., im.verify does not detect truncated images (that most viewers often load with a greyed area).
Pillow is able to detect these type of defects too, but you have to apply image manipulation or image decode/recode in or to trigger the check. Finally I suggest to use this code:
try:
im = Image.load(filename)
im.verify() #I perform also verify, don't know if he sees other types o defects
im.close() #reload is necessary in my case
im = Image.load(filename)
im.transpose(PIL.Image.FLIP_LEFT_RIGHT)
im.close()
except:
#manage excetions here
In case of image defects this code will raise an exception.
Please consider that im.verify is about 100 times faster than performing the image manipulation (and I think that flip is one of the cheaper transformations).
With this code you are going to verify a set of images at about 10 MBytes/sec (modern 2.5Ghz x86_64 CPU).
For the other formats psd,xcf,.. you can use Imagemagick wrapper Wand, the code is as follows:
im = wand.image.Image(filename=filename)
temp = im.flip;
im.close()
But, from my experiments Wand does not detect truncated images, I think it loads lacking parts as greyed area without prompting.
I red that Imagemagick has an external command identify that could make the job, but I have not found a way to invoke that function programmatically and I have not tested this route.
I suggest to always perform a preliminary check, check the filesize to not be zero (or very small), is a very cheap idea:
statfile = os.stat(filename)
filesize = statfile.st_size
if filesize == 0:
#manage here the 'faulty image' case
You can guess by attempting to load the image into memory (using PIL or somesuch), but it's possible that some images could be loaded ok without being complete - for example an animated GIF might load fine if you have the header and the first frame of the animation, and you won't notice that later frames of the animation were missing.
A more reliable approach would probably be to use some out-of-band communication, like rather than watching a folder and processing new files as soon as they exist, find some way of hooking into the downloader process and getting it to give you a signal when it decides it is ready.

Are there any Autopano Server alternative or automated panorama stitching/video panorama open source?

I haven't found any server side panorama making from stitching images or a video. I would like an open source alternative, but found any. I just don't want to go trough the hassle of developing all this on my own since but paid software usually are closed source and not very flexible.
I've seen some nifty panorama from video software in the iphone and thought it would be easy to find on *nix systems but with no luck.
Any help will be appreciated. Thanks in advance.
The only option I know is to use panostart (which is part of hugin) from whatever server language you are using.
See here for more information and other command line tools that do parts of the process more specifically.
panostart just works with images, so obviously if you wanted it to work with videos then you would have to process the videos with something like ffmpeg -i z.mov -f image2 export2\%d.png to generate images to pass to panostart.
The other alternative which requires more effort is to write something that uses libpano13 and libffmpeg directly.
You can have a look to VideoStitch, a command line is provided to automate the stitching.