Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a collection of about 3,000 photographs that represent my company's product line. Each picture is taken inside a special light box. A unique barcode representing the product is generated, printed on a label, and placed alongside each product in the light box.

Is it possible to recognize the unique barcode in each picture programatically and rename the picture based on it?

share|improve this question
    
I probably wouldn't do this with Photoshop. –  Ignacio Vazquez-Abrams Jan 26 '13 at 16:34
    
What encoding do the barcodes use? –  Ignacio Vazquez-Abrams Jan 26 '13 at 16:35
2  
you say, "the photos would be taken in a special lightbox" is there a reason the barcode can't be scanned WHEN taking the photo into the save dialog? –  datatoo Jan 26 '13 at 17:31
    
1. I can print either 1D or 2D barcodes, using MS Access. which "save dialog" are you referring to? My current plan is for the photographer to take the pics as fast as he can and to periodically upload the memory card to his computer. when all 3000 pics are taken, I would then have someone manually rename the pics based on the part ID in the image and then remove the background and crop out the barcode. Please advise on the most efficent procedure to accomplish my objective –  Nathaniel_613 Jan 26 '13 at 18:43
    
If the part ID is in the picture, couldn't you have a bot parse the image for the ID? –  Kruug Jan 29 '13 at 20:22
show 1 more comment

4 Answers 4

up vote 0 down vote accepted

Oh dear! There is actually something "off the shelf that is going to give you the functionality that your are looking for": zbar

#!/bin/bash
for file in $*
do
    name="`zbarimg -q $file`"
    echo "Renaming $file to $name"
    mv $file $name
done

Put that into a file. rename_barcode.sh for instance. And:

chmod u+x rename_barcode.sh
./rename_barcode.sh *.jpg *.png

Of course, it is a bit rough over the edges (what if no barcode is found?), but zbarimg gives you the functionality you want. The remaining part is really just scripting.

EDIT:

Sorry, you didn't mention Linux. The aforementioned script is a bash script assuming that the zbar package is installed. If you are using Windows, you just have to install zbarimg.exe somewhere and create a similar script but using MS Batch syntax.

share|improve this answer
add comment

I doubt your going to find anything off the shelf that is going to give you the functionality that your are looking for. More likely, you would need to write some custom code to parse images for barcodes, read them, then rename the images. Of course this could be not only expensive, but time consuming. So the real question should be is it cheaper to do this by hand, or hire someone to write custom software for you that you may only use a handful of times? Interns are great for either possiblity.

However, if you are willing to write some code, this code sample would be a major head start.

http://www.codeproject.com/Articles/42852/Reading-Barcodes-from-an-Image-III

It does most of the heavy lifting for you, you just need to setup a system to rename your files and add a bit of business logic in order to have it work in a batch setting. I've played with it before and it is very capable as long as your barcodes are visible.

share|improve this answer
add comment

One major problem with the process as asked is that the program needs to identify the barcode without user hinting in an arbitrary image. If the barcode is large with respect to the product in the frame, then you will probably have success. Open source libraries and binaries are available which can read e.g TIFF and return a string. (ZBar was one IIRC http://www.youtube.com/watch?v=rqzQb_HMYf8 )

I have tried this with flat items approx 36 inches square (and no budget) and the barcode size was so large that it crowded out the object in the frame.

I use a camera which is remotely actuated by a networked computer and the software used captures the image directly to a file server and has a text field for appending user text to an auto-naming scheme. I know for a fact that such software is available for professional Canon and Nikon cameras. (I don't want to turn this into an advertisement, so I won't mention product, but the canon-specific software I use I purchased a number of years ago for something on the order of 50$)

Since many barcode scanners can simulate keyboard input, perhaps the photographer can use a similar solution, and then you can introduce a process where you set focus to the field in the software, use a wand reader to swipe the code (entering the part number into the field), then place the item for the shoot. Coupled with an auto timestamp, you will have prenamed files already on the server and no longer have to "sneaker-net" the images off the camera card.

Added bonus is the photographer can view the image on a large monitor prior to moving the item off the set.

(some cameras come bundled with feature limited capture software, so the old standby of having the photographer capture them to disk and then have one of your own people rename them on the fly while the item code is known is going to be better than tackling the task of identifying and renaming 3000 of them later)

share|improve this answer
    
this is the way to do this. Set up the camera with the lightbox. preview on screen and scan the barcode you were going to put into a text field instead of trying to photograph it, then saving will save as the name. You can even build this yourself, but why reinvent the wheel there are plenty of inexpensive programs to do this as @horatio mentions –  datatoo Feb 1 '13 at 2:21
add comment

If the barcode in the image is good enough you should be able to use a standard scanner - much like this one to read the barcode straight from the image.

http://www.amazon.co.uk/My-Link-Barcode-Scanner-Reader-Reading/dp/B000QGSUUK.

They just output the series of characters that are represented by the barcode. You can then just take this to rename the file.

(other scanners are available).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.