Permalink
Browse files

src/libdecodeqr/libdecodeqr.cpp:

 * short qr_decoder_get_status(QrDecoderHandle decoder) and int qr_decoder_is_busy(QrDecoderHandle decoder) are added.

src/sample/webcam/webcam.cpp:
 * add lock mechanisim

git-svn-id: http://www.koka-in.org/svn/libdecodeqr/trunk@34 d649fbcd-581f-0410-8d75-88b9247333c5
  • Loading branch information...
1 parent 45a3259 commit 442f9d3f33dcabe6fc06460f9323d958a670e6aa (no author) committed Jan 3, 2007
Showing with 48 additions and 8 deletions.
  1. +23 −0 src/libdecodeqr/decodeqr.h
  2. +12 −0 src/libdecodeqr/libdecodeqr.cpp
  3. +13 −8 src/sample/webcam/webcam.cpp
View
@@ -68,6 +68,29 @@ extern void qr_decoder_close(QrDecoderHandle decoder);
/////////////////////////////////////////////////////////////////////////
//
+// get status
+//
+// ARGS:
+// QrDecoderHandle decoder: handler
+//
+// RETURN: status code
+//
+extern short qr_decoder_get_status(QrDecoderHandle decoder);
+
+/////////////////////////////////////////////////////////////////////////
+//
+// get working status
+//
+// ARGS:
+// QrDecoderHandle decoder: handler
+//
+// RETURN: status code
+//
+extern int qr_decoder_is_busy(QrDecoderHandle decoder);
+
+
+/////////////////////////////////////////////////////////////////////////
+//
// set source image size
//
// ARGS:
@@ -35,6 +35,18 @@ void qr_decoder_close(QrDecoderHandle decoder)
delete imagereader;
}
+short qr_decoder_get_status(QrDecoderHandle decoder)
+{
+ Qr::ImageReader *imagereader=(Qr::ImageReader *)decoder;
+ return(imagereader->status);
+}
+
+int qr_decoder_is_busy(QrDecoderHandle decoder)
+{
+ Qr::ImageReader *imagereader=(Qr::ImageReader *)decoder;
+ return(imagereader->status&QR_IMAGEREADER_WORKING?1:0);
+}
+
QrDecoderHandle qr_decoder_set_image_size(QrDecoderHandle decoder,
int width,int height,
@@ -43,31 +43,34 @@ int main(int argc,char *argv[])
//
int key=-1;
- IplImage *src=cvQueryFrame(capture);
- if(src)
+ IplImage *camera=cvQueryFrame(capture);
+ IplImage *src=NULL;
+ if(camera){
+ src=cvCloneImage(camera);
qr_decoder_set_image_buffer(decoder,src);
+ }
else
key=1;
unsigned char *text=NULL;
int text_size=0;
while(key<=0){
- cvShowImage("src",src);
+ cvShowImage("src",camera);
key=cvWaitKey(150);
//
// when [SPACE] key pressed, do decode.
//
- if(key==0x20){
+ if(key==0x20&&!qr_decoder_is_busy(decoder)){
key=-1;
//
// if left-bottom origin (MS-Windows style) format,
// it must be converted to left-top origin.
//
- if(src->origin)
- cvConvertImage(src,src,CV_CVTIMG_FLIP);
+ if(camera->origin)
+ cvConvertImage(camera,src,CV_CVTIMG_FLIP);
//
// While decoding is a failure, decrease the
@@ -141,15 +144,17 @@ int main(int argc,char *argv[])
}
}
- src=cvQueryFrame(capture);
- if(!src)
+ camera=cvQueryFrame(capture);
+ if(!camera)
break;
}
if(text)
delete text;
qr_decoder_close(decoder);
+ if(src)
+ cvReleaseImage(&src);
cvReleaseCapture(&capture);
return(0);

0 comments on commit 442f9d3

Please sign in to comment.