Zxing to landscape screen recognition to landscape screen Recognition

Source: Internet
Author: User

Apache license 2.0 open-source zxing Project

There are too many things for zxing Android projects, many of which we don't need. We need to create another project to simplify it.

 

Before you begin, let's briefly introduce the responsibilities of various packages and classes used to simplify zxing.

Captureactivity. This is to start the activity, that is, the scanner (if it is the first installation, it will jump to the help interface ).
Captureactivityhandler decoding class, which calls another thread for decoding.
The decodethread decoding thread.
Com. Google. zxing. Client. Android. Camera package and camera control package.
The custom view of viewfinderview is the frame in the middle of the shooting.

 

Solution:

1. Modify the decode method in decodehandler. java.
Planaryuvluminancesource source = cameramanager. Get (). buildluminancesource (data, width, height );
Is
Byte [] rotateddata = new byte [data. Length];
For (INT y = 0; y For (INT x = 0; x <width; X ++)
Rotateddata [x * height + height-y-1] = data [x + y * width];
}
Int TMP = width; // here we are swapping, that's the difference to #11
Width = height;
Height = TMP;

Planaryuvluminancesource source = cameramanager. Get (). buildluminancesource (rotateddata, width, height );

2. In cameramanager. Java, comment on the Code:
// Rect. Left = rect. Left * cameraresolution. X/screenresolution. X;
// Rect. Right = rect. Right * cameraresolution. X/screenresolution. X;
// Rect. Top = rect. Top * cameraresolution. Y/screenresolution. Y;
// Rect. Bottom = rect. Bottom * cameraresolution. Y/screenresolution. Y;
Change
Rect. Left = rect. Left * cameraresolution. Y/screenresolution. X;
Rect. Right = rect. Right * cameraresolution. Y/screenresolution. X;
Rect. Top = rect. Top * cameraresolution. X/screenresolution. Y;
Rect. Bottom = rect. Bottom * cameraresolution. X/screenresolution. Y;

3. In cameraconfigurationmanager. Java, add a sentence in the setdesiredcameraparameters method.
Camera. setdisplayorientation (90 );

4. In androidmanifest. XML, set the activity attribute Android: screenorientation = "Landscape"
Change
Android: screenorientation = "portrait"

Compile and run it!

Refer:

Http://code.google.com/p/zxing/issues/detail? Id = 178 # c46

Code:

Https://github.com/pplante/zxing-android

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.