I'm new to arduino and I have followed tutorial on this page:
and able to do the frame capture. Can anyone makes tutorial how to read QR code from those captured images using arduino uno and OV7670?
I'm new to arduino and I have followed tutorial on this page:
and able to do the frame capture. Can anyone makes tutorial how to read QR code from those captured images using arduino uno and OV7670?
You are trying to program a CV algorithm on an 8-bit microcontroller with 2k of RAM? That's
never going to work, you can't even hold a tiny fraction of the image in memory.
Use OpenCV on your computer to process the images - that instructible shows how to spool
an image through an Uno to the host computer, it cannot store the image in the Uno.
Normally you'd just use a cheap USB webcam with OpenCV directly.
I have already tried read QR using webcam base on this tutorial:
I need to read QR using microcontroller or something similar. I have looked on the internet that we can read QR real time using raspberry pi but I don't know how to use it. Can you make tutorial or suggest some sources to read QR code real time using microcontroller?
I need to read QR using microcontroller or something similar. I have looked on the internet that we can read QR real time using raspberry pi but I don't know how to use it
That would be a question to ask in a forum that supports the Raspberry Pi or Pi Zero.
Here you go. Now you just need to port the necessary libraries and adapt the code to work on an Arduino:
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <zbar.h>
#include <iostream>
using namespace cv;
using namespace std;
using namespace zbar;
//g++ main.cpp /usr/local/include/ /usr/local/lib/ -lopencv_highgui.2.4.8 -lopencv_core.2.4.8
void setup() {
VideoCapture cap(0); // open the video camera no. 0
// cap.set(CV_CAP_PROP_FRAME_WIDTH,800);
// cap.set(CV_CAP_PROP_FRAME_HEIGHT,640);
if (!cap.isOpened()) { // if not success, exit program
cout << "Cannot open the video cam" << endl;
return -1;
}
ImageScanner scanner;
scanner.set_config(ZBAR_NONE, ZBAR_CFG_ENABLE, 1);
double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video
cout << "Frame size : " << dWidth << " x " << dHeight << endl;
namedWindow("MyVideo", CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"
}
void loop() {
Mat frame;
bool bSuccess = cap.read(frame); // read a new frame from video
if (!bSuccess) //if not success, break loop
{
cout << "Cannot read a frame from video stream" << endl;
break;
}
Mat grey;
cvtColor(frame, grey, CV_BGR2GRAY);
int width = frame.cols;
int height = frame.rows;
uchar *raw = (uchar *)grey.data;
// wrap image data
Image image(width, height, "Y800", raw, width * height);
// scan the image for barcodes
int n = scanner.scan(image);
// extract results
for (Image::SymbolIterator symbol = image.symbol_begin();
symbol != image.symbol_end();
++symbol) {
vector<Point> vp;
// do something useful with results
cout << "decoded " << symbol->get_type_name() << " symbol "" << symbol->get_data() << '"' <<" "<< endl;
int n = symbol->get_location_size();
for (int i = 0; i < n; i++) {
vp.push_back(Point(symbol->get_location_x(i), symbol->get_location_y(i)));
}
RotatedRect r = minAreaRect(vp);
Point2f pts[4];
r.points(pts);
for (int i = 0; i < 4; i++) {
line(frame, pts[i], pts[(i + 1) % 4], Scalar(255, 0, 0), 3);
}
//cout<<"Angle: "<<r.angle<<endl;
}
imshow("MyVideo", frame); //show the frame in "MyVideo" window
if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
{
cout << "esc key is pressed by user" << endl;
break;
}
}
If starting with OpenCV I'd strongly suggest using Python, not C++, simpler and you get all of numpy and scipy
at your disposal too.