Problems with ZXing C 1.5 Version porting to the phone

62 views
Skip to first unread message

MrGao

unread,
Jul 24, 2010, 8:43:28 PM7/24/10
to zxing
Hi everyone:

I am a newbie in ZXing and C++. First timer using JNI in my android
development.
I am working on a project which use the phone to take pictures of
QRcode and then detect and decode the code.
Originally we coded the application in Java. Now we decide to use the C
++ version since this is much faster.

We made the ZXing C 1.4 Version working and can call everything from
Java through JNI.
But we want to use the ZXing C 1.5 Version now. The problem is that
Zxing C 1.5 is vastly different from 1.4.

Where can I find the document about the changes that has been made?
Or if there is no document about those changes. I have the following
code in C1.4, can anyone give me some sample codes which accomplish
the same thing?


The codes are :




int detFiducialPoint(IplImage *imgGray,
double *imgPts,
QRInfo *qrParam)
{
QRCodeReader myQRCodeReader;

//Convert image to ZXing format
Ref<GrayBytesMonochromeBitmapSource> qrimg(new
GrayBytesMonochromeBitmapSource ((const unsigned char *)imgGray-
>imageData,imgGray->width,imgGray->height, imgGray->widthStep));

//Decode QR codes
Ref<Result> result = myQRCodeReader.decode(qrimg);

//Get fiducial points
ArrayRef<Ref<ResultPoint> > points(result->getResultPoints());
if (points->size() != NUM_FIDUCIAL_PTS){
cout<<"Insufficient number of fiducial points
detected."<<endl;
return -1;
}

//Copy fiducial points (in the order of FP1,2,3 and AP in "Z"
order)
imgPts[0]= points[1]->getY();
imgPts[1]= points[1]->getX();
imgPts[2]= points[2]->getY();
imgPts[3]= points[2]->getX();
imgPts[4]= points[0]->getY();
imgPts[5]= points[0]->getX();
imgPts[6]= points[3]->getY();
imgPts[7]= points[3]->getX();

cout<<"fiducial points = [";
for (size_t i = 0; i < points->size(); i++) {
cout << imgPts[2*i] << "," << imgPts[2*i+1] << ";";
}
cout<<"]"<<endl;
cout<<"contents = "<<*(result->getText())<<endl;

Version version = result->getVersion();
qrParam->version = version.getVersionNumber();
qrParam->numModPerAxis = version.getDimensionForVersion();

///////////////////////////////////////
qrParam->lengthInMeter = 0.2; //eventually to be read from QR
code itself
///////////////////////////////////////

//cout<<"qrver="<<qrParam->version<<endl;
//cout<<"qrnumline="<<qrParam->numModPerAxis<<endl;

return 0;
}

A lot of classes have been changed and
"GrayBytesMonochromeBitmapSource " is not even there anymore.

I found some example code at :
http://code.google.com/p/zxing/source/browse/trunk/cpp/magick/src/example.cpp?spec=svn1144&r=1144

But I do not know for what reason, tt seems that I can not use
anything related to
"Magick++.h", I downloaded "MagickBitmapSource.h" and
""MagickBitmapSource.cpp", and include "MagickBitmapSource.h" in my
code in order to use

Ref<MagickBitmapSource> source(new MagickBitmapSource(image));

as in the example.

It seem this line of code is not compilable because of "Magick++.h".
Anyone has any idea how to solve this?

Any help will be appreciated!

Thanks!

Weihua Gao






Any help will be appreciated.

Ralf

unread,
Jul 25, 2010, 3:38:44 AM7/25/10
to zxing
MagickBitmapSource is used for images loaded from a file with the
ImageMagick library. You should probably use GreyscaleLuminanceSource
instead.

Ralf
> I found some example code at :http://code.google.com/p/zxing/source/browse/trunk/cpp/magick/src/exa...

MrGao

unread,
Jul 25, 2010, 3:40:18 PM7/25/10
to zxing
Dear Ralf and all:
I replace
Ref<GrayBytesMonochromeBitmapSource> qrimg(new
GrayBytesMonochromeBitmapSource ((const unsigned char *)imgGray-
>imageData,imgGray->width,imgGray->height, imgGray->widthStep));

with these two lines:

Ref<GreyscaleLuminanceSource> source(NULL);

source = new GreyscaleLuminanceSource ((const unsigned char *)imgGray-
>imageData,imgGray->width,imgGray->height, 0,0, imgGray->width,imgGray-
>height);
//Ref<GreyscaleLuminanceSource> qrimg(new GreyscaleLuminanceSource
((const unsigned char *)imgGray->imageData,imgGray->width,imgGray-
>height, 0,0, imgGray->width,imgGray->height));


When I compile the codes, the compiler gave the following information:



Android NDK: Building for application 'qrReaderWithOpenCVnew'
Compile++ thumb: qrreader <= apps/qrReaderWithOpenCVnew/qrjni.cpp
In file included from apps/qrReaderWithOpenCVnew/qrjni.h:17,
from apps/qrReaderWithOpenCVnew/qrjni.cpp:15:
build/platforms/android-4/arch-arm/usr/include/jni.h:489: note: the
mangling of 'va_list' has changed in GCC 4.4
apps/qrReaderWithOpenCVnew/qrjni.cpp: In function 'int
detFiducialPoint(IplImage*, double*, QRInfo*)':
apps/qrReaderWithOpenCVnew/qrjni.cpp:211: error: cannot allocate an
object of abstract type 'zxing::GreyscaleLuminanceSource'
apps/qrReaderWithOpenCVnew/qrreader/zxing/common/
GreyscaleLuminanceSource.h:27: note: because the following virtual
functions are pure within 'zxing::GreyscaleLuminanceSource':
apps/qrReaderWithOpenCVnew/qrreader/zxing/common/LuminanceSource.h:33:
note: virtual int zxing::LuminanceSource::getWidth()
apps/qrReaderWithOpenCVnew/qrreader/zxing/common/LuminanceSource.h:34:
note: virtual int zxing::LuminanceSource::getHeight()
apps/qrReaderWithOpenCVnew/qrreader/zxing/common/LuminanceSource.h:36:
note: virtual unsigned char zxing::LuminanceSource::getPixel(int,
int)
make: *** [out/apps/qrReaderWithOpenCVnew/armeabi/objs/qrreader/
qrjni.o] Error 1

Is this "GreyscaleLuminanceSource" an abstract class or did I do
anything wrong here?

Thank you for your help!

Weihua
Reply all
Reply to author
Forward
0 new messages