Languages

Menu
Sites
Language
QrCodeRecognizer dosen't recognize code from image file?

Hi

Is it possible to use QrCodeRecognizer to recognized codes from loaded images (JPG/PNG)?

 

According to my tests the engine works ok for camera previvew pixelformat PIXEL_FORMAT_YCbCr420_PLANAR.

But I can't make it work for files.

 

pBuffer = img.DecodeToBufferN(filePath, BITMAP_PIXEL_FORMAT_ARGB8888 , destImgW, destImgH); // loading image with perfect code quality resolution: 640x640
r = __pQrRecognizer->SetImageSize(destImgW, destImgH);
r = __pQrRecognizer->ProcessImage(pBuffer);  // returns nothing

 

Above I use BITMAP_PIXEL_FORMAT_ARGB8888 but changing to other pixelformat gets not effect as well. The recognizer returns none result.

I suppose there is problem with pixel format inside ByteBuffer. So far it works only for camera overlayformat PIXEL_FORMAT_YCbCr420_PLANAR and NV12

on ref device RD-210.

 

I tested it on UI and separately thread as well - if it has any matter at all.

 

Now I stuck totally. Probably I have to implement external engine like zxing.

 

 

Responses

6 Replies
Pushpa G

Hi,

Use the API Tizen::Media::Camera::GetSupportedPreviewFormatListN() and check what are the formats supported . I guess as of now only the above two formats are supported(NV12 and PIXEL_FORMAT_YCbCr420_PLANAR ). However check in the latest version 2.2.1(binary: http://download.tizen.org/releases/2.2.1/tizen-2.2.1/images/RD-PQ/)

Pushpa G

Hi,

Sorry, it can work on files also but you need to specify PIXEL_FORMAT_YCbCr420_PLANAR  or NV12 format in the argument.

And also i heard that you need to convert the BITMAP_PIXEL_FORMAT_ARGB8888 to grey format and then use the converted format, then BITMAP_PIXEL_FORMAT_ARGB8888 also works/is supported

Slawek Kowalski

Still doesn't work.

I load bitmap:

pBuffer = img.DecodeToBufferN(path, BITMAP_PIXEL_FORMAT_ARGB8888 , destImgW, destImgH);

 

and convert pixelFormat:

                  	Tizen::Base::ByteBuffer destBuf2;
              		int rgbBufSize = destImgW * destImgH; // for GRAY 8 bits per pixel
              		destBuf2.Construct(rgbBufSize);
              		destBuf2.SetPosition(0);
              		destBuf2.SetLimit(rgbBufSize);
              		Dimension dim;
              		dim.width = destImgW;
              		dim.height = destImgH;
              		  r = Tizen::Media::ImageUtil::ConvertPixelFormat(*pBuffer,
              				destBuf2,
              				MEDIA_PIXEL_FORMAT_RGBA8888,
              				MEDIA_PIXEL_FORMAT_GRAY ,
              				dim
              			);

 

and process the buffer:

pQrRecognizer->SetImageSize(destImgW, destImgH);
pQrRecognizer->ProcessImage(destBuf2);

pQrRecognizer->GetRecognizedObjectCount() returns 0.

 

Loaded pattern/bitmap is JPG or PNG 640x640 and contains clear qr-code gnerated by a qr-generator. I always tests for a few pictures to be sure is ok.

 

 

I am couries what condition it must met in order to recognize image delivered from other source than camera.

 

 

 

Pushpa G

You need to create a buffer of YCbCr format from ARGB888 and then create a byte buffer out of it

Slawek Kowalski

I am not very familiar with video formats.

YCbCr format is not explicitly available in media formats - Tizen::Media::MediaPixelFormat.

I found MEDIA_PIXEL_FORMAT_YUV420P equals PIXEL_FORMAT_YCbCr420_PLANAR.

For Tizen::Media::ImageUtil::ConvertPixelFormat() I can deliver some of media formats - I put MEDIA_PIXEL_FORMAT_YUV420P.

Now I decode picture with BITMAP_PIXEL_FORMAT_ARGB8888  by DecodeToBufferN then convert to

                 	  r = Tizen::Media::ImageUtil::ConvertPixelFormat(*pBuffer,
              				destBuf2,
              				MEDIA_PIXEL_FORMAT_RGBA8888,
              				MEDIA_PIXEL_FORMAT_YUV420P,
              				dim
              			);

and finally:

                    	Tizen::Base::ByteBuffer destBuf3;
                		int buffSize = destImgW * destImgH; // for GRAY 1 byte per pixel
                		destBuf3.Construct(buffSize);
                		destBuf3.SetPosition(0);
                		destBuf3.SetLimit(buffSize);
              		  r = Tizen::Media::ImageUtil::ConvertPixelFormat(destBuf2,
              				destBuf3,
              				MEDIA_PIXEL_FORMAT_YUV420P,
              				MEDIA_PIXEL_FORMAT_GRAY,
              				dim
              			);

and

pQrRecognizer->ProcessImage(destBuf3);// still 0 results on output

I am not sure

MEDIA_PIXEL_FORMAT_YUV420P

Is that equivalent for format PIXEL_FORMAT_YCbCr420_PLANAR?

and I assume there is 1 byte per pixel for GRAY format.

 

Kav Nico

I also meet the same problem when I want to recognize qr code. Who can tell me how to resolve it?