Ask Your Question
0

QR code detection in Java (Android Studio)

asked 2019-04-04 11:08:36 -0600

Agus gravatar image

Hi everyone,I´m developing a final project Android app, where I´m using OpenCV, everything works fine until I´ve tried to detect and decod QR codes, I´ve been trying to understand how can I use this java code: https://docs.opencv.org/4.0.1/javadoc... Can someone explain me how it works? or at least a working example in java about how to use it. Thanks so much and best regards.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2019-04-05 02:42:18 -0600

berak gravatar image

updated 2019-04-05 02:46:21 -0600

detecting (single !) qr codes is fairly simple,

unfortunately, as of now(4.1.0), you cannot use the decode functionality from java, due to:

//
// C++:  string cv::QRCodeDetector::decode(Mat img, Mat points, Mat& straight_qrcode = Mat())
//

// Return type 'string' is not supported, skipping the function
edit flag offensive delete link more

Comments

Thanks berak, so QRCodeDetector in java is half implemented, it´s so weird...Anyways, could be possible to implement that decode functionality by myself? Thanks and regards.

Agus gravatar imageAgus ( 2019-04-05 03:24:54 -0600 )edit

@berak, For 3.4 branch I have:

//
// C++:  String cv::QRCodeDetector::decode(Mat img, Mat points, Mat& straight_qrcode = Mat())
//

//javadoc: QRCodeDetector::decode(img, points, straight_qrcode)
public  String decode(Mat img, Mat points, Mat straight_qrcode)
{

    String retVal = decode_0(nativeObj, img.nativeObj, points.nativeObj, straight_qrcode.nativeObj);

    return retVal;
}

//javadoc: QRCodeDetector::decode(img, points)
public  String decode(Mat img, Mat points)
{

    String retVal = decode_1(nativeObj, img.nativeObj, points.nativeObj);

    return retVal;
}
dkurt gravatar imagedkurt ( 2019-04-05 04:42:37 -0600 )edit

Oh, that's looks like a lack of tests because in the master branch I got:

//
// C++:  string cv::QRCodeDetector::decode(Mat img, Mat points, Mat& straight_qrcode = Mat())
//

// Return type 'string' is not supported, skipping the function


//
// C++:  string cv::QRCodeDetector::detectAndDecode(Mat img, Mat& points = Mat(), Mat& straight_qrcode = Mat())
//

// Return type 'string' is not supported, skipping the function
dkurt gravatar imagedkurt ( 2019-04-05 04:47:29 -0600 )edit

yes, cv::String (3.4) vs. std::string (master)

(imho, in the long run, the java wrappers need to learn how to support std::string (again))

berak gravatar imageberak ( 2019-04-05 05:08:35 -0600 )edit
1

@berak, @Agus, Proposed a hot fix here: https://github.com/opencv/opencv/pull....

(imho, in the long run, the java wrappers need to learn how to support std::string (again))

@berak, +1

dkurt gravatar imagedkurt ( 2019-04-05 05:49:26 -0600 )edit

Thanks @berak@dkurt!

Agus gravatar imageAgus ( 2019-04-05 07:20:24 -0600 )edit

So, after all the changes made thanks to your proposal, can I use Detect and Decode functions on my Android project? Regards.

Agus gravatar imageAgus ( 2019-04-05 10:45:42 -0600 )edit

Check a test code from the PR. Method detectAndDecode returns a string from an image with QRCode.

dkurt gravatar imagedkurt ( 2019-04-05 13:03:06 -0600 )edit

Sorry @dkurt@berak, I´m totally lost.... I´m still in the 4.0.1 OpenCV version, so how to import those changes into my Android Studio project?

Agus gravatar imageAgus ( 2019-04-05 13:11:02 -0600 )edit

do this issue still persist on ver. 4.4.0? currently exploring the possibiliy of using opencv for android qr code scanner and could use some help from u guys some simple answer like yes or no wil be much appreciated

A Guy called Nate gravatar imageA Guy called Nate ( 2020-07-07 22:24:26 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-04-04 11:08:36 -0600

Seen: 2,840 times

Last updated: Apr 05 '19