A journal documenting the progress on code prototyping for the webcam barcode scanner using opencv and zxing.
(Last updated 4/5) -Clarence
4/23/18
Oh boy Oberto,
I finally figured out how to connect zxing and opencv together. using cmake. I want to be able to do this without cmake, but for now this is one step closer.
First I downloaded cmake and installed it.
I used cmake to open up opencv and generate a project with it. The opencv project generated by cmake will have a file named "OpenCVConfig.cmake". On windows I open up "System" in the control panel. Then I open the Advance System Settings, so I can add the "Path" to the bin file that includes all the ".dll" file generated by the cmake to the Environmental Variable in the System Variables. Then I restarted my computer so the paths would load.
Afterwards I downloaded the ZXing and I used cmake to generate a project for ZXing, it wont beable to find the path for opencv. Then I clicked on the CMAKE_INSTALL_PREFIX line and I browsed for the opencv project I created. Then clicked on the configure, button and then the generate button. This will create a project that includes opencv. However there are 4 .dll files needed to be added to the source files. They are located in the bin folder in the opencv project.
There will be a zxing-cv project already made and you added files to that source.
The four files are: opencv_core341d.dll, opencv_highgui341d.dll, opencv_imgproc341d.dll, and opencv_videoio341d.dll.
I had to go in to the code and comment out the QR code related lines so it could read the bar code for some reason.
Breakthrough! 4/5/18
Today, I finally got zxing to scan an image. The files can be found on the google drive under the folder "codes".
You can download and test it out on various image files by dragging and dropping an image file onto the .exe file located in the debug folder.
I already have a few images in the debug folder for you to test. Currently the code does not scan well on low resolution images, The lines between the bars must be distinct. My webcam on my laptop was not able to take pictures sharp enough for the code reader, but my phone can. Another thing is the image must be cropped. So far the code does not crop the image and if it is not cropped it will fail to scan. I had to manually crop the image for it to work.
I also have an image reader that writes the image to file. You will find the execute file under the x64 debug folder. If you double click on the execute file it will turn on your webcam if you have the file path of the opencv. Two boxes will open up and one will be gray while the other will have an image. To save an image click on the gray window and press escape. It will terminate the program and save the image into the debug folder.
To install opencv on windows 10, first download opencv and extract it to a location you know. Then press the start button ("the windows button located on the bottom left of your screen by default") and search for system. Click on the 'System' under settings. Then click on 'Advance System Settings' and 'System Properties' window will open up. Under the 'Advance' tab click on 'Environment Variables'. A window will open up for 'Environment Variables' and there will be two boxes, The lower box is named 'System Variables' and there is a row called 'Path'. Click on it and press 'Edit', and a new window called 'Edit environment variables will open up. Then click new and paste the file path for the opencv into that box. Restart your computer and opencv should work.
4/1/18
Today I have discovered that ZXing has a code reader inside that automatically returns a cropped image of the barcode. There is two code readers, one is the codabarReader that reads the bar code directly, but I am not sure what type of data it takes.
The other is the multiFormatReader that can read all codes and takes a binary bit map. This suppose to return a cropped image.
I have a code that creates a binary bit map of barcodes.
3/30/18
I have been experimenting with different ways to transform an image in opencv and I found a way to use less memory when I store the image to a variable. I can use pyrDown() to shrink and image down by half its height and half its width before storing it into a variable.
I have figured out how the wifi code works for the arduino, but I have not gotten the code to load.
I also had the idea to detect the bar code and crop the image so I only store the bar code. I got this idea from another blog I found and he had a
3/28/18
Today I looked at the spec sheet for the ArduCam for the first time and I noticed that the SPI rate can be at 8MHZ, and since its a 2MP camera. I am guessing that it can be cranked up to 4 frames per second.
I was able to get the code to load on the arduino, but I wasn't able use the image.
3/27/18
I haven't found any good source on a opencv with zxing.
I found one which is from a software site, and they have a .exe file of their software. I am not sure if it I can get their code through a .exe file.
Here is their website, and they were able to use opencv and zxing in c++ to capture a barcode with a webcam.
Meanwhile I am learning how to program for opencv to see if I can store a image file in a variable and send it to zxing.
so far I have found out that cv::Mat is an object that can store a single frame.
cv::VideoCapture is another object that works like cin.get() and it works by grabbing a single frame from a video.
each time you run the object created by cv::VideoCapture it will take a single frame from the video file and the frame can be stored in a object variable created by cv::Mat.
I am going to see if I can send a single frame stored with an image of a bar code into zxing to get analyzed.