Can a picture file be renamed based on a unique barcode contained within the picture?

4

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?

Nathaniel_613

Posted 2013-01-26T16:31:16.533

Reputation: 235

I probably wouldn't do this with Photoshop. – Ignacio Vazquez-Abrams – 2013-01-26T16:34:31.457

What encoding do the barcodes use? – Ignacio Vazquez-Abrams – 2013-01-26T16:35:14.937

2you 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 – 2013-01-26T17:31:40.223

>

  • 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 – 2013-01-26T18:43:28.700

    If the part ID is in the picture, couldn't you have a bot parse the image for the ID? – Kruug – 2013-01-29T20:22:06.433

    Use barcode font ... it may ID be too ... – STTR – 2013-01-29T22:22:50.013

    Answers

    0

    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.

    user183734

    Posted 2013-01-26T16:31:16.533

    Reputation:

    2

    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.

    Lee Harrison

    Posted 2013-01-26T16:31:16.533

    Reputation: 2 046

    1

    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)

    horatio

    Posted 2013-01-26T16:31:16.533

    Reputation: 3 345

    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 – 2013-02-01T02:21:20.093

    0

    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).

    ChrisF

    Posted 2013-01-26T16:31:16.533

    Reputation: 39 650