Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: mazbox/ofxmarek
base: 8b72be0f82
...
head fork: mazbox/ofxmarek
compare: f5380b044e
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 2 contributors
Commits on Nov 21, 2011
@stecca stecca I needed a realtime version so I quickly created an overload for the …
…findQR function, now taking a second parameter that gives control on precision over speed. I can use the function for realtime setting the adaption_levels near or equal to 1, or have a very precise version (not for real time) setting adaption_levels near or equal to 6.
96a8980
@mazbox Merge pull request #1 from stecca/patch-3
I needed a realtime version so I quickly created an overload for the fin...
f5380b0
Showing with 46 additions and 0 deletions.
  1. +46 −0 ofxQRDecoder/ofxQRDecoder.h
View
46 ofxQRDecoder/ofxQRDecoder.h
@@ -50,6 +50,52 @@ class ofxQRDecoder {
return decodedString;
}
+ //@Overload
+ //findQR
+ // image: the image to explore to find codes
+ // adaption_levels: higher for more precision, lower for fast elaboration (real-time).
+ //
+ // NOTES: Values below 1 will be interpreted as 1, values above 6 will be interpreted as 6
+ string findQR(ofxCvGrayscaleImage image, unsigned short adaption_levels) {
+ if (adaption_levels<=0) adaption_levels = 1;
+ if (adaption_levels>6) adaption_levels=6;
+
+ try {
+ // set the image to analyze
+ qr_decoder_set_image_buffer(decoder,image.getCvImage());
+
+ // try different levels of adaptiveness until we've decoded an image
+ short sz,stat;
+ sz = 25;
+ unsigned short deltaSize = round(sz / adaption_levels) - (adaption_levels % 2); // calculate delta from levels, round the value and assure it is a multiple of 2
+ for(sz=25,stat=0; (sz>=3)&&((stat&QR_IMAGEREADER_DECODED)==0); sz-=deltaSize) {
+ stat=qr_decoder_decode(decoder,sz);
+ }
+
+ if(stat==QR_IMAGEREADER_DECODED) {
+ QrCodeHeader header;
+ if(qr_decoder_get_header(decoder,&header)){
+ //
+ // get QR code text
+ // To null terminate, a buffer size is larger than body size.
+ //
+ char buf[header.byte_size+1];
+ qr_decoder_get_body(decoder,(unsigned char *)buf,header.byte_size+1);
+ decodedString = buf;
+ timeDiscovered = ofGetElapsedTimef();
+ }
+ }
+ } catch(int i) {
+ printf("We had an error from the Qr code reader\n");
+ qr_decoder_set_status(decoder, 0);
+ }
+ if(ofGetElapsedTimef() - timeDiscovered>1.f) {
+ decodedString = "";
+ }
+ return decodedString;
+ }
+
+
private:
QrDecoderHandle decoder;
string decodedString;

No commit comments for this range

Something went wrong with that request. Please try again.