CN105930757A - Method and device for scanning two-dimensional code - Google Patents

Method and device for scanning two-dimensional code Download PDF

Info

Publication number
CN105930757A
CN105930757A CN201610244863.2A CN201610244863A CN105930757A CN 105930757 A CN105930757 A CN 105930757A CN 201610244863 A CN201610244863 A CN 201610244863A CN 105930757 A CN105930757 A CN 105930757A
Authority
CN
China
Prior art keywords
camera
image
scan box
preview
resolution
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201610244863.2A
Other languages
Chinese (zh)
Inventor
陆舟
于华章
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Feitian Technologies Co Ltd
Original Assignee
Feitian Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Feitian Technologies Co Ltd filed Critical Feitian Technologies Co Ltd
Priority to CN201610244863.2A priority Critical patent/CN105930757A/en
Publication of CN105930757A publication Critical patent/CN105930757A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/10544Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation by scanning of the records by radiation in the optical part of the electromagnetic spectrum
    • G06K7/10712Fixed beam scanning
    • G06K7/10722Photodetector array or CCD scanning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1408Methods for optical code recognition the method being specifically adapted for the type of code
    • G06K7/14172D bar codes

Landscapes

  • Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Electromagnetism (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Toxicology (AREA)
  • Artificial Intelligence (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Studio Devices (AREA)

Abstract

The present invention discloses a method and device for scanning a two-dimensional code. The method comprises the steps that an application starts a system camera; the application obtains a camera image through the camera preview frame of the system camera, rotates the camera image, and obtains a scanning frame image corresponding to a scanning frame in the rotated camera image according to the rotated camera image and the position of a scanning frame image in the rotated camera image; and the application decodes the obtained scanning frame image. According to the invention, only the scanning frame image which comprises a two-dimensional code image corresponding to the scanning frame in the camera preview frame is analyzed, the analysis of other images outside the scanning frame is not needed, and the decoding efficiency is improved.

Description

A kind of method and apparatus scanning Quick Response Code
Technical field
The present invention relates to the communications field, particularly relate to a kind of method and apparatus scanning Quick Response Code.
Background technology
Two-dimensional bar code/Quick Response Code (2-dimensional bar code) is by necessarily with certain specific geometric figure The chequered with black and white figure that rule is distributed in plane (on two-dimensional directional), may be used for recording data symbol letter Breath, has high density coding, the features such as information capacity is big, and coding range is wide.
In prior art, when scanning Quick Response Code, need user that image in 2 D code is placed on the preview of camera In frame, the image got by the preview pane of camera is included outside image in 2 D code and image in 2 D code Other images;When image is resolved, need all images got by the preview pane of camera Resolve so that decoding efficiency is low, the longest.
Summary of the invention
The invention aims to overcome the deficiencies in the prior art, it is provided that a kind of method scanning Quick Response Code and Device.
A kind of method scanning Quick Response Code that the present invention provides, including:
Step S1: application starts system camera;
Step S2: described application obtains camera image by the camera preview frame of described system camera, by described Camera image rotates, according to postrotational camera image and scan box image at described postrotational camera Position in image, obtains the scan box image corresponding with scan box in camera image after rotation;
Step S3: the scan box image got is decoded by described application.
The present invention provide a kind of device scanning Quick Response Code, including: start module, the first acquisition module and Decoder module;
Including: start module, the first acquisition module and decoder module;
Described startup module, is used for starting system camera;
Described first acquisition module, after starting described system camera when described startup module, by described The camera preview frame of system camera obtains camera image, is rotated by described camera image, after rotating Camera image and scan box image position in described postrotational camera image, camera after rotation Image obtains the scan box image corresponding with scan box;
Described decoder module, is decoded for the scan box image getting described first acquisition module.
The present invention compared with prior art, has the advantage that
The present invention provide a kind of method and apparatus scanning Quick Response Code, only to the scanning in camera preview frame What frame was corresponding includes that the scan box image of image in 2 D code resolves, it is not necessary to other outside scan box Image resolves, and improves decoding efficiency.
Accompanying drawing explanation
Fig. 1 is the flow chart of a kind of method scanning Quick Response Code that the embodiment of the present invention 1 provides;
Fig. 2 and Fig. 3 is the flow chart of a kind of method scanning Quick Response Code that the embodiment of the present invention 2 provides;
Fig. 4 is the flow chart of step 114 in the embodiment of the present invention 2;
The structure chart of a kind of device scanning Quick Response Code that Fig. 5 provides for the embodiment of the present invention 3.
Detailed description of the invention
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clearly Chu, be fully described by, it is clear that described embodiment be only a part of embodiment of the present invention rather than Whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art are not making creation The every other embodiment obtained under property work premise, broadly falls into the scope of protection of the invention.
Embodiment 1
Embodiments of the invention 1 provide a kind of method scanning Quick Response Code, as it is shown in figure 1, include:
Step S1: application starts system camera;
Step S1 specifically includes:
Application arranges the readjustment of interfacial level controller, and application creates camera object;Apply according to the camera pair created As, obtain Current camera parameter;Apply according to camera object, start the camera preview frame of system camera.
Step S2: apply and obtain camera image by the camera preview frame of system camera, camera image is carried out Rotate, according to the position in postrotational camera image and scan box image camera image after rotation, Postrotational camera image obtains the scan box image corresponding with scan box;
Step S3: the scan box image got is decoded by application.
Specifically, the application decoding data to the scan box image got, it is judged that decoding is the most successful, It is to determine scanning Quick Response Code success, terminate, otherwise return step S2.
In this enforcement, can also include before starting system camera: application judges whether system camera exists, If it is, startup system camera, perform step S2;Otherwise, terminate.
In the present embodiment, before camera image is rotated, also include: application obtains dividing of current screen Resolution, obtains the immediate value with the resolution of current screen in the preview graph size that system camera is supported and makees For the camera resolution of system camera, camera image is set according to camera resolution.
Wherein, obtain the resolution of current screen, including:
Step S4-1: apply the window services provided according to system, obtains the forms manager pair of current application As;
Step S4-2: application, according to the forms manager object got, creates the object of forms display class;
Step S4-3: apply the object according to the forms display class created, obtain the resolution of current screen;
Step S4-4: application judges that whether the value of the attribute x in the resolution of current screen is less than attribute y's Value, is the value of the attribute x in the resolution of current screen to be swapped with the value of attribute y, determine and obtain Get the resolution of current screen, otherwise determine the resolution getting current screen.
Wherein, in the preview graph size that system camera is supported, acquisition is immediate with the resolution of current screen It is worth as camera resolution, including:
Step A01: application initializes camera resolution abscissa, camera resolution vertical coordinate, the first difference Sum counter;
Step A02: apply according to the second preset characters string, obtain the object of template class;
Step A03: application is according to the object of the template class got, the preview graph chi supported by Current camera Very little it is divided into preview graph size character string array;
Step A04: application judges that whether the value of enumerator is more than the data in preview graph size character string array Number, is then to perform step A12, otherwise performs step A05;
Step A05: apply the preview that acquisition is corresponding with the value of enumerator in preview graph size character string array Figure size character string, i.e. current preview figure size;
Step A06: application obtains the 3rd preset characters string position in current preview figure size as segmentation Position;
Step A07: apply and obtain the data before split position and split position in current preview figure size, Update camera resolution abscissa according to the data got, apply in current preview figure size, obtain segmentation Data after position, update camera resolution vertical coordinate according to the data got;
Step A08: camera resolution abscissa, camera resolution vertical coordinate and current screen are divided by application Resolution calculates, and obtains current difference;
Step A09: application judges whether current difference is 0, is then to perform step A11, otherwise performs step A10;
Specifically, computation camera resolution abscissa and the attribute x's in the resolution of current screen is exhausted To value, calculate the absolute value of camera resolution vertical coordinate and the attribute y in the resolution of current screen, by two Secondary calculated absolute value is sued for peace, and obtains current difference, it is judged that whether current difference is 0, is to perform step Rapid A11, otherwise performs step A10.
Step A10: application judges that current difference, whether less than the first difference, is then to update according to current difference First difference, refresh counter, return step A04;Otherwise refresh counter, returns step A04;
Step A11: application judges whether camera resolution abscissa and camera resolution vertical coordinate are all higher than 0, It is then to perform step A12, otherwise terminates;
Step A12: apply using camera resolution abscissa and camera resolution vertical coordinate as parameter, create The object of system coordinates point class is as camera resolution.
In the present embodiment, according in postrotational camera image and scan box image camera image after rotation Position, before camera image after rotation obtains the scan box image corresponding with scan box, also include: Apply according to current application father's layout, scan box layout and camera image, calculate scan box image after rotation Camera image in position.
Wherein, according to current application father's layout, scan box layout and camera image, calculate scan box image and exist Position in postrotational camera image, including:
Step B01: application obtains the distance between left side and the left side of current application father's layout of scan box layout As topology file scan box left summit abscissa, obtain top and current application father's layout of scan box layout Top between distance as topology file scan box left summit vertical coordinate, obtain the width of preview pane layout As topology file preview pane width;Obtain the height of preview pane layout as topology file preview pane height;
Step B02: apply according to topology file scan box left summit abscissa, topology file preview pane width and The height of camera image obtains the abscissa on the left summit in scan box image camera image after rotation, root Obtain according to the width of topology file scan box left summit vertical coordinate, topology file preview pane height and camera image The vertical coordinate on the left summit in scan box image camera image after rotation, sweeps according to default topology file Retouch width of frame, the height of camera image and topology file preview pane width and obtain scan box image after rotation Width in camera image, according to default topology file scan box height, the width of camera image and layout Previewing file frame height obtains the height in scan box image camera image after rotation.
Wherein, the abscissa on the left summit in scan box image camera image after rotation is that topology file is swept Retouch frame left summit abscissa and be multiplied by the height of camera image again divided by topology file preview pane width;Scanning block diagram As the vertical coordinate on the left summit in camera image after rotation is that topology file scan box left summit vertical coordinate is taken advantage of With the width of camera image again divided by topology file preview pane height;Scan box image camera figure after rotation The topology file scan box width that width in Xiang is default is multiplied by the height of camera image again divided by topology file Preview pane width;Height in scan box image camera image after rotation is default topology file scanning Frame height is multiplied by the width of camera image again divided by topology file preview pane height.
In the present embodiment, apply and obtain camera image by the camera preview frame of system camera, particularly as follows: should Adjust back with the auto-focusing arranging system camera and preview is adjusted back, apply the camera preview frame by system camera Obtain camera image.
Wherein, the auto-focusing readjustment and the preview that arrange system camera are adjusted back, including:
Step S7-1: the auto-focusing callback object of application establishment system auto-focusing readjustment class, according to establishment Auto-focusing callback object arrange system camera auto-focusing readjustment;
Step S7-2: application establishment system preview readjustment class object;
Step S7-3: apply according to the preview readjustment class object created and camera object, system camera is set Preview is adjusted back.
In the present embodiment, according to position and the scan box image camera after rotation of postrotational camera image Position in image, in camera image after rotation obtain the scan box image corresponding with scan box particularly as follows: Apply the left top in the wide height according to postrotational camera image, scan box image camera image after rotation Wide height in the coordinate of point and scan box image camera image after rotation, in camera image after rotation Obtain the scan box image corresponding with scan box.In the present embodiment, carry out rotating by camera image particularly as follows: Camera image dextrorotation is turn 90 degrees by application.
The present embodiment provide a kind of method scanning Quick Response Code, only to the scan box pair in camera preview frame The scan box image including image in 2 D code answered resolves, it is not necessary to other images outside scan box Resolve, improve decoding efficiency.Further, apply the resolution by obtaining current screen, be The preview graph size that system camera is supported obtains the immediate value of resolution with current screen as system camera Camera resolution, camera image is set according to camera resolution, camera image and camera preview frame can be made More mate, and then make scan box image more mate with scan box, thus ensure that application can get completely Image in 2 D code while reduce the redundant digit outside the image in 2 D code in scan box image to greatest extent According to, and also can be avoided and cause the camera image got because the camera resolution of system camera is too high Data excessive, and then the data of the scan box image because getting in camera image after rotation excessive and Reduce the efficiency of decoding.It addition, application is according to current application father's layout, scan box layout and camera image, Calculate the position in scan box image camera image after rotation, it is possible to more accurately determine scan box image and exist Position in postrotational camera image, improves acquisition in camera image after rotation corresponding with scan box The speed of scan box image, further improves the efficiency of decoding.
Embodiment 2
Embodiments of the invention 2 provide a kind of method scanning Quick Response Code, as shown in Figures 2 and 3, bag Include:
Step 101: application obtains current application father's layout according to the object ID of the current application father's layout preset Object, obtain the object of scan box layout according to the object ID of default scan box layout, according to default Interface view control ID, obtains the control of interface view class, i.e. interface view object;
Specifically, application is according to the object ID of the current application father's layout preset, calling system method FindViewById method obtains the object mContainer of current application father's layout;According to default scan box The object ID of layout, calling system method findViewById method obtains the object of scan box layout mCropLayout;According to default interface view SurfaceView control ID, calling system method FindviewViewById method obtains the control of interface view SurfaceView class, and the control got is Interface view surfaceView object;
Step 102: application is by the interfacial level controller of the control of interface view object acquisition interface view class;
Specifically, application is by interface view surfaceView object reference system approach getHolder method Obtain the interfacial level controller surfaceHolder of the control of interface view SurfaceView class;
Step 103: application creates the object of interfacial level controller class, and according to interfacial level controller class right created As arranging the readjustment of interfacial level controller;
Specifically, application creates the object of interfacial level controller SurfaceHolder.Callback class, and is made For parameter, the addCallback method called in interfacial level controller surfaceholder arranges interfacial level controller Readjustment;
It should be noted that, the object of interfacial level controller SurfaceHolder.Callback class includes SurfaceCreated method, when application using the object of interfacial level controller SurfaceHolder.Callback class as Parameter, the addCallback method in interfacial level controller surfaceholder of calling arranges returning of interfacial level controller After tune;Application can receive the notice from system by the surfaceCreated method of system.
Step 104: when application receives after the notice of system by the surfaceCreated method of system, Application creates camera object;
Specifically, the parameter from system is received when application by the surfaceCreated method of system After SurfaceHolder holder, application judges to be received from being by the surfaceCreated method of system The notice of system, the open method of application call system Camera class creates camera object camera;
Step 105: application judges whether camera object is empty, is to terminate, and otherwise performs step 106;
Step 106: apply according to the camera object created and the interfacial level controller got, system camera is set Live preview show;
Specifically, apply the interfacial level controller surfaceHolder that gets as parameter, call camera pair As the setPreviewDisplay method of camera, the live preview arranging system camera shows;
Step 107: apply according to the camera object created, obtain Current camera parameter object;
Specifically, the getParameters method of application call camera object camera, obtain the method and return The object of Camera.Parameters class as Current camera parameter object parameters;
Step 108: apply the window services provided according to system, obtains the forms manager object of current application;
Specifically, the window services that system provides is Context.WINDOW_SERVICE, and application is by system The window services provided obtains current application as parameter, calling system method getSystemService WindowManager class object is as forms manager object;
Step 109: application, according to the forms manager object got, creates the object of forms display class;
Specifically, the getDefaultDisplay method in the forms manager object that application call gets, wound Build the object display of forms display Display class;
Step 110: apply the object according to the forms display class created, obtain the resolution of current screen;
Specifically, apply the resolution object screenResolution of current screen as parameter, call window The getSize method of the object display of body display Display class obtains the resolution of current screen, and will obtain The resolution of the current screen got is assigned to resolution screenResolution of current screen;
Such as, the resolution of current screen is 1184x768;
Step 111: application judges that whether the value of the attribute x in the resolution object of current screen is less than attribute y Value, be then execution step 112, otherwise perform step 113;
Such as, in the resolution object screenResolution of current screen, the value of attribute x is 1184, currently The value 768 of attribute y, the then resolution pair of current screen in the resolution object screenResolution of screen Value as the attribute x in screenResolution is not less than the value of attribute y;
Step 112: the value of the attribute x in the resolution object of current screen is carried out by application with the value of attribute y Exchange, performs step 113,
Step 113: apply according to the first preset characters string and Current camera parameter object, obtains Current camera and props up The preview graph size held;
Specifically, the first preset characters string is preview-size-values, applies the first character string as ginseng Number, the get method calling Current camera parameter object parameters obtains the preview graph chi that Current camera is supported Very little previewSizeValueString;
Such as, preview graph size previewSizeValueString of Current camera support is: 1280x960, 1280x720,800x480,720x480,640x480,576x432,480x320,384x288,352x288, 320x240,240x160,176x144;
Step 114: apply and obtain the resolution pair with current screen in the preview graph size that Current camera is supported As immediate value is as camera resolution;
Such as, the camera resolution obtained is 1280x720;
Step 115: apply according to camera resolution, arranges the width of camera image in Current camera parameter object High;
Specifically, camera resolution as parameter, is called Current camera parameter object parameters by application SetPreviewSize method, the wide high of camera image in Current camera parameter object parameters is set;
Such as, a height of 1280x720 of width of the camera image in Current camera parameter object parameters;
Step 116: application, according to predetermined angle, arranges the side that the preview graph in Current camera parameter object shows To;
Specifically, predetermined angle is 90, and predetermined angle as parameter, is called Current camera parameter pair by application As the setDisplayOrientation method of parameters, Current camera parameter object parameters is set In the direction that shows of preview graph;
Step 117: apply the wide height according to the camera image in the above-mentioned Current camera parameter object being provided with The direction shown with preview graph, arranges the camera parameter of system camera;
Specifically, Current camera parameter object parameters as parameter, is called camera object by application The setParameters of camera arranges the camera parameter of system camera;
Step 118: apply object, the object of scan box layout and camera image according to current application father's layout Wide high, calculate the coordinate on the scan box image left summit in camera image and the wide high of scan box image;
Step 119: apply according to camera object, start camera preview frame;
Specifically, the startPreview method of application call camera object camera starts camera preview frame;
Step 120: the auto-focusing callback object of application establishment system auto-focusing readjustment class, according to create Auto-focusing callback object arranges the auto-focusing readjustment of system camera;
Specifically, apply the auto-focusing callback object autoFocusCallback of establishment as parameter, adjust It is that system camera arranges auto-focusing readjustment by the autoFocus method of camera object camera;
It should be noted that, auto-focusing callback object autoFocusCallback includes onAutoFocus side Method, when application using the auto-focusing callback object autoFocusCallback of establishment as parameter, calls camera The autoFocus method of object camera is that after system camera arranges auto-focusing readjustment, application can be by being The onAutoFocus method of system receives the notice from system.
Step 121: when application receives after the notice of system by the onAutoFocus method of system, Application establishment system preview readjustment class object;
Specifically, when application receives parameter success from system by the onAutoFocus method of system, After camera, application judges to receive the notice from system by the onAutoFocus method of system, The object previewCallback of application establishment system preview readjustment class PreviewCallback class;
Step 122: apply according to the preview readjustment class object created and camera object, the pre-of system camera is set Look at readjustment;
Specifically, the object previewCallback of class PreviewCallback is adjusted back in the preview created by application As parameter, the setOneShotPreviewCallback method calling camera object camera is system camera Preview readjustment is set;
It should be noted that, preview readjustment class object previewCallback includes onPreviewFrame method, When application using the object previewCallback of preview readjustment class PreviewCallback of establishment as parameter, Calling the setOneShotPreviewCallback method of camera object camera is that system camera arranges preview and returns After tune, application can receive the notice from system by the onPreviewFrame method of system.
Step 123: when application receives the notice from system by the onPreviewFrame method of system After, application obtains camera image from the parameter of onPreviewFrame method;
Specifically, parameter data from system is received when application by the onPreviewFrame method of system After camer, application judges to receive the notice from system by the onPreviewFrame method of system, Application obtains camera image from parameter data of onPreviewFrame method.
In the present embodiment, image exists the most in the form of data.
Such as, camera image data data that application gets is:
0C0A08080809080807080808090A0B0A090B0B0B0B0C0C0B0B0B0C0D0E0C0E0B 0D0F0F100C0E0F0F0C0D0D111112100E0C0D0F100D0C0A0809080B08050707070606 05060606050507060706050607070706050708080707070707080808080707070809 0908070707070909090807090908090A09080707070908080A090809090809090909 08070B0908080A090B0A0A0A0908090A0A0A090A09090908080A090707070706 07070605050505050505060705050505060606050504050505060808080807070707 070808080808090A0A090A0A0A0A0D0D0C0E0C0C0D0E0D0D0E0D0C0D0D0D 0D0D0E0F0D0C0D0F1011110D0B0C0C0D0B0B0C0D0A0A … … 7161719171A191919191917181818181919191818181A18171818181917171A1918 18181A1817161918181818181717161819191A1B1A1A181A19181B18181A18191 91A19191A1B1A1C1C1C1B1C1E202023242426292A2B2A2B2B2B2D2E2D2C2B 2A2928262321201F1E1C1C1F1E1E1E1F212220202021201F201E1C1B1C1A1919 1917191B1B1B1B1E1E1F1F1F1F2020222223202123242525252524232224212424 25232221211F20211D1C1C1C1C191A19181716161515161718191A1B1B1C1B1E 1F1D1D1E1B1D1E1D1D1E1F21221F2021242325;
Step 124: the camera image got is rotated by application, is revolved according to the wide height of camera image The wide height of the camera image after Zhuaning;
Specifically, the camera image dextrorotation got is turn 90 degrees, by high for the width of camera image phase by application The interchangeable wide height as postrotational camera image;
More specifically, apply and change according to the data of the presetting method camera image to getting, make Camera image dextrorotation turn 90 degrees, and makes the wide height of camera image be exchanged with each other as postrotational camera figure The wide height of picture.
Wherein, presetting method can particularly as follows:
Wherein, height is the height (720) of the camera image before rotating, before width is for rotating The width (1280) of camera image;Data is the data of the camera image before rotating, and rotatedData is The data of postrotational camera image.
Such as, the data of the camera image after conversion are:
2A2F2D2B2C2A2826282B2D2D2C2E363031302E302E302F313336353436383836 35313332353735353635373737373635353635353233383134383634323134343434 343233343636343536333637363A3E393B3C393A3B3A3C3E403D3B3E3E3A3F3B403D 413C3D3E3C413D403F3C3D3E3C3E3C3F3B3A383C3C3D41413D383D3E3A3E3C3C3C 3C3B3936393E3C3D3E3C3A3A3D3D403F413F433D3C3C3B3C3C3C3A373C3A 3D3B383C39363B343638383A38373838373837393C393535343439373532363736 38373533373737353737363837363438393637353535353938373735363436373136 363A3A393938383936373735363837363433373539363638383634353636393C3E3 639373534353B3C3A393A3B34333636373A38353738373 … … 536343239383836353738383736363738363635383A3637363436383838343635343 63733343536353334343736363538383436353437363637383635353839393635353 837383536373737363737363837363737353637383736373535363437363A3636343 63536353838363536333738353437343436373735353A34323334353537353634343 6373A3937363635363634353735363A363436373634353336333538353635343436 38383432313132353635323637363837353536363433343338353436343434333633 363734323335353635332F3235333430323435333234333336373637363735323535 36343435353433333232353539373835353535353334353532333536363631353536 36353234343334333836343232333232313134343232343030323032312F2E313132 313131333234313535343132353031313333333432343433333134343332312E2E31 34342E2E2F3232323031303033313132333233353331312F3133322F303133313330 2C2F2E323031302F2F3;
Wherein, a height of 1280x720 of width of camera image, a height of 720x1280 of width of postrotational camera image;
Step 125: apply the wide height according to postrotational camera image, scan box image in camera image The coordinate on left summit and the wide height of scan box image, obtain corresponding with scan box in camera image after rotation Scan box image, the scan box image got is decoded;
Specifically, application is according to wide height, Boolean constant true, the scan box image of postrotational camera image Left summit abscissa x, the scan box image left summit vertical coordinate y in camera image and scan box image Wide high, camera image after rotation obtains the scan box image corresponding with scan box, to the scanning got Block diagram picture is decoded;
Such as, a width of the 720 of postrotational camera image, a height of the 1280 of postrotational camera image, sweep The left summit abscissa x retouching block diagram picture is 172, and the left summit vertical coordinate y of scan box image is 225, scanning A width of the 187 of block diagram picture, a height of the 225 of scan box image;
More specifically, application uses wide height, Boolean constant true, the scan box of postrotational camera image Left summit vertical coordinate y in camera image of the left summit abscissa x of image, scan box image and scanning block diagram The wide height of picture, obtains the scanning block diagram corresponding with scan box in calling system method camera image after rotation Picture, is decoded the scan box image got.
In this step, system approach includes but not limited to: zbar_image_set_crop ().
Step 126: application judges that decoding is the most successful, is, determines scanning Quick Response Code success, terminates, otherwise Return step 120;
In the present embodiment, step 114 is applied and obtains in the preview graph size that Current camera is supported with current The immediate value of resolution object of screen is as camera resolution, as shown in Figure 4, particularly as follows:
Step A01: application initializes camera resolution abscissa, camera resolution vertical coordinate and the first difference;
Such as, the initial value of camera resolution abscissa and camera resolution vertical coordinate is 0, the first difference Initial value is the first preset value Integer.MAX_VALUE;Such as, the first preset value Integer.MAX_VALUE is 3354191829;
Step A02: apply according to the second preset characters string, obtain the object of template class;
Specifically, the second preset characters string is ", ", applies the second preset characters string as parameter, adjusts Obtain the object of template Pattern class by Pattern.compile method, i.e. the object of template Pattern class is ", ";
Step A03: application is according to the object of the template class got, the preview graph chi supported by Current camera Very little it is divided into preview graph size character string array;
Specifically, preview graph size previewSizeValueString that Current camera is supported by application is as ginseng Number, calls the split method of the object of template Pattern class, the preview graph size supported by Current camera PreviewSizeValueString is divided into preview graph size character string array;
Such as, preview graph size previewSizeValueString of Current camera support is: 1280x960, 1280x720,800x480,720x480,640x480,576x432,480x320,384x288,352x288, 320x240,240x160,176x144, the preview graph size character string array that segmentation obtains is:
Step A04: application initialization counter;
Such as, the initial value of enumerator is 0;
Step A05: application judges that whether the value of enumerator is more than the data in preview graph size character string array Number, is then to perform step A13, otherwise performs step A06;
Such as, the data amount check in preview graph size character string array is 12;
Step A06: apply the preview that acquisition is corresponding with the value of enumerator in preview graph size character string array Figure size character string, i.e. current preview figure size;
Specifically, the preview graph that acquisition is corresponding with the value of enumerator in preview graph size character string array is applied Size character string, creates the object of character string String class, i.e. current preview figure sized objects previewSize;
Step A07: application obtains the position conduct in current preview figure sized objects of the 3rd preset characters string Split position;
Specifically, the 3rd preset characters string is " x ", and the 3rd preset characters string as parameter, is called by application The indexOf method of current preview figure sized objects previewSize, obtains the 3rd preset characters string currently Split position dimPosition in preview graph sized objects previewSize;
Such as, current preview figure sized objects previewView is 1280x960, the split position got DimPosition is 4;
Step A08: apply before obtaining split position and split position in current preview figure sized objects Data, update camera resolution abscissa according to the data got, apply at current preview figure sized objects Data after middle acquisition split position, update camera resolution vertical coordinate according to the data got;
Specifically, application as parameter, calls current preview figure size using 0 and split position dimPosition The subString method of object previewSize obtains the character string on 0 to split position dimPosition, And using the character string that gets as parameter call Integer.parseInt method, obtain the data of int type, and Camera resolution abscissa newX is updated according to the data obtained;
Specifically, split position dimPosition is added 1 as parameter by application, calls current preview figure size The subString method of object previewSize obtains the character string after split position dimPosition, and Using the character string that gets as parameter call Integer.parseInt method, obtain the data of int type, and root Camera resolution vertical coordinate newY is updated according to the data obtained;
Such as, the camera resolution abscissa newX after renewal is 1280, and the camera resolution after renewal is indulged Coordinate newY is 960;
Step A09: camera resolution abscissa, camera resolution vertical coordinate and current screen are divided by application Resolution object calculates, and obtains current difference;
Specifically, application is by the resolution object of camera resolution abscissa newX Yu current screen The difference of the attribute x in screenResolution, as parameter, calls the calculating of Math.abs method the poorest The absolute value of value, by the resolution object of camera resolution vertical coordinate newY Yu current screen The difference of the attribute y in screenResolution, as parameter, calls the calculating of Math.abs method the poorest The absolute value of value, by twice calculated absolute value summation, obtains current difference newDiff;
Such as, camera resolution abscissa newX is 1280, and camera resolution vertical coordinate newY is 960, In the resolution object screenResolution of current screen, the value of attribute x is 1184, the resolution of current screen The value 768 of attribute y in rate object screenResolution;Camera resolution abscissa newX and current screen In the resolution object screenResolution of curtain, the absolute value of the difference of the value of attribute x is 96, and camera is differentiated The difference of the value of attribute y in rate vertical coordinate newY and the resolution object screenResolution of current screen Absolute value be 192, the summation of twice calculated absolute value, the current difference newDiff obtained is 288;
Step A10: application judges whether current difference is 0, is then to perform step A12, otherwise performs step A11;
Step A11: application judges that current difference, whether less than the first difference, is then to update according to current difference First difference, refresh counter, return step A05;Otherwise refresh counter, returns step A05;
Such as, current difference newDiff is 288, and the first difference is 3354191829, then current difference is less than First difference, is updated to 288 by the first difference;
Step A12: application judges whether camera resolution abscissa and camera resolution vertical coordinate are all higher than 0, It is then to perform step A13, otherwise terminates;
Step A13: apply using camera resolution abscissa and camera resolution vertical coordinate as parameter, create The object of system coordinates point class is as camera resolution;
In the present embodiment, step 118 is applied the object according to current application father's layout, scan box layout Object and the wide height of camera image, calculate coordinate and the scanning on the scan box image left summit in camera image The wide height of block diagram picture, particularly as follows:
Step B01: application obtain scan box layout object on the left of with the object of current application father's layout on the left of it Between distance as topology file scan box left summit abscissa, obtain the object top of scan box layout and work as Distance between the object top of front application father's layout, as topology file scan box left summit vertical coordinate, obtains The width of the object of preview pane layout is as topology file preview pane width;Obtain the object of preview pane layout Height is as topology file preview pane height;
Specifically, the getLeft method of the object mCropLayout of application call scan box layout, acquisition is swept Retouch on the left of the object mCropLayout of frame layout and between the object mContainer of current application father's layout Distance, i.e. topology file scan box left summit abscissa x;Call the object mCropLayout of scan box layout GetTop method, obtain object mCropLayout top and current application father's layout of scan box layout Distance between object mContainer, i.e. topology file scan box left summit vertical coordinate y;Call preview pane The getWidth method of the object mContainer of layout, obtains the object mContainer's of preview pane layout Width, i.e. topology file preview pane width;Call the getHeight of the object mContainer elephant of preview pane layout Method, obtains the height of the object mContainer of preview pane layout, i.e. topology file preview pane height;
Such as, topology file scan box left summit abscissa x is 184, and the left summit of topology file scan box is vertical to be sat Mark y is 200, and topology file preview pane width is 768, and topology file preview pane height is 1134;
In the present embodiment, topology file preview pane is corresponding with the preview pane of camera, topology file scan box and phase Scan box in the preview pane of machine is corresponding.
It should be noted that, the coordinate on the left summit of topology file scan box can also is that default.
Step B02: apply according to topology file scan box left summit abscissa, topology file preview pane width and The height of camera image obtains the abscissa on the scan box image left summit in camera image, according to layout literary composition The width of part scan box left summit vertical coordinate, topology file preview pane height and camera image obtains scanning block diagram As the vertical coordinate on the left summit in camera image, according to default topology file scan box width, camera figure Height and the topology file preview pane width of picture obtain scan box image width in camera image, according in advance If topology file preview pane height, the width of camera image and topology file scan box height obtain scan box Image height in camera image;
Such as, topology file scan box left summit abscissa x is 184, and the left summit of topology file scan box is vertical to be sat Mark y is 200, and topology file scan box width is 768, and topology file scan box height is 1134, camera figure The height of picture is 720, and the width of camera image is 1280, the topology file scan box width preset and height It is 200;
The abscissa x on the left summit of scan box image is that topology file scan box left summit abscissa x is multiplied by phase The height of machine image obtains scan box image divided by topology file preview pane width, i.e. (184*720)/768 again The abscissa x on the left summit in camera image is 172;
The vertical coordinate y on the left summit of scan box image is that topology file scan box left summit vertical coordinate y is multiplied by phase The width of machine image obtains scanning block diagram divided by topology file preview pane height, i.e. (200*1280)/1134 again As the vertical coordinate y on the left summit in camera image is 225;
The topology file scan box width that the width of scan box image is default is multiplied by the height of camera image and removes Scan box image width in camera image is obtained with topology file preview pane width, i.e. (200*720)/768 Degree is 187;
The topology file scan box height that the height of scan box image is default is multiplied by the width of camera image and removes Scan box image is obtained in camera image with topology file preview pane height, i.e. (200*1280)/1134 It is highly 225.
A kind of method scanning Quick Response Code provided in the present embodiment, it is possible to the scan box image according to obtaining exists Coordinate in camera image and the wide height of scan box image, get scan box image from camera image, When camera image in the preview pane of camera is resolved, only corresponding with scan box is included Quick Response Code The scan box image of image resolves, it is not necessary to resolve other images outside scan box, improves Decoding efficiency.
Embodiment 3
Present embodiments provide a kind of device scanning Quick Response Code, as it is shown in figure 5, include: startup module 01, First acquisition module 02 and decoder module 03;
Start module 01, be used for starting system camera;
Wherein, start module 01 and include Interface Control submodule, the first establishment submodule, the first startup submodule Block and the 5th obtains submodule;
Interface Control submodule, for arranging the readjustment of interfacial level controller;
First creates submodule, after Interface Control submodule arranges the readjustment of interfacial level controller, creates phase Machine object;
5th obtains submodule, for creating, according to first, the camera object that submodule creates, obtains current phase Machine parameter;
First promoter module, for creating, according to first, the camera object that submodule creates, starts system phase The camera preview frame of machine.
First acquisition module 02, after starting system camera when startup module 01, by the phase of system camera Machine preview pane obtain camera image, camera image is rotated, according to postrotational camera image and with sweep Retouch in block diagram picture camera image after rotation, camera image after rotation obtains corresponding with scan box Scan box image;
Decoder module 03, is decoded for the scan box image getting the first acquisition module 02.
In the present embodiment, device can also include judge module, it is judged that module is for starting when startup module 01 Before system camera, it is judged that whether system camera exists;Correspondingly, module 01 is started specifically for when judging After module is judged to be, start system camera.
In the present embodiment, device can also include: the second acquisition module;Second acquisition module includes that first obtains Take submodule, the second acquisition submodule and first arranges submodule;
First obtains submodule is used for, before camera image is rotated by the first acquisition module 02, obtaining and working as The resolution of forth screen;Second obtain submodule for system camera support preview graph size in obtain with First obtains the immediate value of resolution of the current screen that submodule gets as camera resolution;First Submodule is set camera image is set for the camera resolution got according to the second acquisition submodule.
Wherein, the first acquisition submodule includes: the first acquiring unit, the first creating unit, the second acquisition list Unit and the second judging unit;
First acquiring unit, for the window services provided according to system, obtains the forms management of current application Device object;
First creating unit, for the forms manager object got according to the first acquiring unit, creates window The object of body display class;
Second acquisition unit, the object of the forms display class for creating according to the first creating unit, obtain and work as The resolution of forth screen;
Second judging unit, the genus in the resolution judging current screen that second acquisition unit gets Property x value whether value less than attribute y, be then by value and the genus of the attribute x in the resolution of current screen The value of property y swaps, and determines the resolution getting current screen, otherwise determines and get current screen Resolution.
Wherein, second obtain submodule include: initialization unit, the 3rd acquiring unit, the first cutting unit, 3rd judging unit, the second creating unit, the 4th acquiring unit, the first updating block, the first computing unit, 4th judging unit, the 5th judging unit, the 6th judging unit and the 3rd creating unit;
Initialization unit, is used for initializing camera resolution abscissa, camera resolution vertical coordinate, first poor Value sum counter;
3rd acquiring unit, for according to the second preset characters string, obtaining the object of template class;
First cutting unit, the object of the template class for getting according to the 3rd acquiring unit, by current phase The preview graph sized divisions of machine support is preview graph size character string array;
3rd judging unit, for judging whether the value of enumerator is more than in preview graph size character string array Data amount check;
When the 3rd judging unit, second creating unit, for judging that the value of enumerator is not more than preview graph size word When according with the data amount check in string array, obtain corresponding with the value of enumerator in preview graph size character string array Preview graph size character string, i.e. current preview figure size;
4th acquiring unit, for obtaining the current preview that the 3rd preset characters string obtains in the second creating unit Position in figure size is as split position;
First updating block, for obtaining framing bits in the current preview figure size that the second creating unit obtains Put and data before split position, update camera resolution abscissa according to the data got, apply Current preview figure size obtains the data after split position, updates camera according to the data got and differentiate Rate vertical coordinate;
First computing unit, differentiates for the camera resolution abscissa obtaining the first updating block, camera The resolution of rate vertical coordinate and current screen calculates, and obtains current difference;
4th judging unit, is used for judging whether current difference is 0;
5th judging unit, for when the 4th judging unit judges that current difference is not 0, it is judged that current Whether difference, less than the first difference, is, updates the first difference, refresh counter according to current difference, triggers 3rd judging unit is operated;Otherwise refresh counter, triggers the 3rd judging unit and is operated;
6th judging unit, for when the 4th judging unit judges that current difference is 0, it is judged that camera divides Whether resolution abscissa and camera resolution vertical coordinate are all higher than 0;
3rd creating unit, for judging that when the 3rd judging unit the value of enumerator is more than preview graph size word Accord with the data amount check in string array, or the 6th judging unit judges that camera resolution abscissa and camera divide When resolution vertical coordinate is all higher than 0, using camera resolution abscissa and camera resolution vertical coordinate as parameter, Create the object of system coordinates point class as camera resolution.
Further, the first computing unit, specifically for calculating camera resolution abscissa and current screen The absolute value of the attribute x in resolution, calculates in the resolution of camera resolution vertical coordinate and current screen The absolute value of attribute y, by twice calculated absolute value summation, obtains current difference.
In the present embodiment, device can also include: the first computing module;
First computing module is used at the first acquisition module 02 according to postrotational camera image and scan box image The position in camera image after rotation, obtains sweep corresponding with scan box in camera image after rotation Before retouching block diagram picture, according to current application father's layout, scan box layout and camera image, calculate scanning block diagram As the position in camera image after rotation.
First computing module includes: the 5th acquiring unit and the second computing unit;
5th acquiring unit, for obtaining between the left side of scan box layout and the left side of current application father's layout Distance as topology file scan box left summit abscissa, obtain top and the current application of scan box layout Distance between the top of father's layout, as topology file scan box left summit vertical coordinate, obtains preview pane layout Width as topology file preview pane width;Obtain the height of preview pane layout as topology file preview pane Highly;
Second computing unit, horizontal for the left summit of topology file scan box got according to the 5th acquiring unit The height of coordinate, topology file preview pane width and camera image obtains scan box image camera after rotation The abscissa on the left summit in image, the left summit of topology file scan box got according to the 5th acquiring unit The width of vertical coordinate, topology file preview pane height and camera image obtains scan box image phase after rotation The vertical coordinate on the left summit in machine image, according to default topology file scan box width, the height of camera image The topology file preview pane width that degree and the 5th acquiring unit get obtains scan box image phase after rotation Width in machine image, obtains according to default topology file scan box height, the width of camera image and the 5th Take the topology file preview pane height that unit gets to obtain in scan box image camera image after rotation Highly.
Further, the second computing unit, specifically for being multiplied by left for topology file scan box summit abscissa The height of camera image, again divided by topology file preview pane width, obtains scan box image camera after rotation The abscissa on the left summit in image;Left for topology file scan box summit vertical coordinate is multiplied by the width of camera image Degree, again divided by topology file preview pane height, obtains the left top in scan box image camera image after rotation The vertical coordinate of point;Default topology file scan box width is multiplied by the height of camera image again divided by layout literary composition Part preview pane width, obtains the width in scan box image camera image after rotation;By default layout File scan frame height is multiplied by the width of camera image again divided by topology file preview pane height, obtains scan box Height in image camera image after rotation.
In the present embodiment, the first acquisition module 02 can include the 3rd acquisition submodule, the first gyrator module Submodule is obtained with the 4th;
3rd obtains submodule is used for, after startup module 01 starts system camera, arranging the automatic of system camera Focusing readjustment and preview are adjusted back;Camera image is obtained by the camera preview frame of system camera;
First gyrator module is for rotating the camera image that the 3rd acquisition submodule gets;
4th obtains submodule, the scanning in the camera resolution according to system camera and camera preview frame Frame position, obtains the scan box image corresponding with scan box in camera image after rotation.
Further, the 3rd obtain submodule and include: first unit, the 4th creating unit are set, second set Put unit and the 6th acquiring unit;
First arranges unit, after starting system camera when startup module 01, creates system auto-focusing and returns The auto-focusing callback object of tone category, the auto-focusing callback object according to creating arranges the automatic of system camera Focusing readjustment;
4th creating unit, after when first, the auto-focusing readjustment that unit arranges system camera is set, wound Build system preview readjustment class object;
Second arranges unit, for the preview readjustment class object created according to the 4th creating unit and camera object, The preview readjustment of system camera is set;
6th acquiring unit, after arranging, when second, the preview readjustment that unit arranges system camera, by being The camera preview frame of system camera obtains camera image.
In the present embodiment, the first acquisition module 02 can be specifically for starting system camera when startup module 01 After, obtain camera image by the camera preview frame of system camera, camera image is rotated, according to rotation The coordinate on the left summit in wide high, the scan box image camera image after rotation of the camera image after Zhuaning and Wide height in scan box image camera image after rotation, obtains in camera image after rotation and scans The scan box image that frame is corresponding.
In the present embodiment, the first acquisition module 02 can also be specifically for starting system phase when startup module 01 After machine, obtain camera image by the camera preview frame of system camera, camera image dextrorotation turn 90 degrees, According to the position in postrotational camera image and scan box image camera image after rotation, after rotation Camera image in obtain the scan box image corresponding with scan box.
In the present embodiment, decoder module 03, specifically for the scanning block diagram getting the first acquisition module 02 The decoding data of picture, it is judged that decoding is the most successful, is, determines scanning Quick Response Code success;Correspondingly, First acquisition module 02 be additionally operable to when decoder module 03 be judged to no after, by the camera preview of system camera Frame obtains camera image, is rotated by camera image, according to postrotational camera image and scan box image The position in camera image after rotation, obtains sweep corresponding with scan box in camera image after rotation Retouch block diagram picture.
A kind of device scanning Quick Response Code provided in the present embodiment, it is possible to the scan box image according to obtaining exists Coordinate in postrotational camera image and the wide height of scan box image, get from the image of camera and sweep Retouch the scan box image that frame is corresponding, when the image in the preview pane to camera resolves, only to scanning The scan box image of what frame was corresponding include image in 2 D code resolves, it is not necessary to its outside scan box He resolves by image, improves decoding efficiency.
Above, the only present invention preferably detailed description of the invention, but protection scope of the present invention is not limited to This, any those familiar with the art, in technical scope disclosed by the invention, can readily occur in Change or replacement, all should contain within protection scope of the present invention.Therefore, protection scope of the present invention Should be as the criterion with scope of the claims.

Claims (30)

1. the method scanning Quick Response Code, it is characterised in that including:
Step S1: application starts system camera;
Step S2: described application obtains camera image by the camera preview frame of described system camera, by described Camera image rotates, according to postrotational camera image and scan box image at described postrotational camera Position in image, obtains the scan box image corresponding with scan box in camera image after rotation;
Step S3: the scan box image got is decoded by described application.
Method the most according to claim 1, it is characterised in that include before described startup system camera: Described application judges whether system camera exists, if it is, start described system camera, performs step S2; Otherwise, terminate.
Method the most according to claim 1, it is characterised in that described described camera image is revolved Before Zhuaning, also include: described application obtain current screen resolution, described system camera support pre- Look at and figure size obtains the immediate value of resolution with current screen differentiate as the camera of described system camera Rate, arranges described camera image according to described camera resolution.
Method the most according to claim 3, it is characterised in that the resolution of described acquisition current screen, Including:
Step S4-1: the window services that described application provides according to described system, obtains the forms of current application Manager object;
Step S4-2: described application, according to the described forms manager object got, creates forms display class Object;
Step S4-3: described application, according to the object of the described forms display class created, obtains current screen Resolution;
Step S4-4: described application judges that whether the value of the attribute x in the resolution of current screen is less than attribute y Value, be the value of the attribute x in the resolution of current screen to be swapped with the value of attribute y, determines Get the resolution of current screen, otherwise determine the resolution getting current screen.
Method the most according to claim 3, it is characterised in that described support at described system camera Preview graph size obtains with the immediate value of resolution of current screen as camera resolution, including:
Step A01: described application initialize camera resolution abscissa, camera resolution vertical coordinate, first Difference sum counter;
Step A02: described application, according to the second preset characters string, obtains the object of template class;
Step A03: described application is according to the object of the template class got, the preview supported by Current camera Figure sized divisions is preview graph size character string array;
Step A04: described application judges that whether the value of enumerator is more than in preview graph size character string array Data amount check, is then to perform step A12, otherwise performs step A05;
Step A05: described apply in preview graph size character string array obtain corresponding with the value of enumerator Preview graph size character string, i.e. current preview figure size;
Step A06: described application obtains the position conduct in current preview figure size of the 3rd preset characters string Split position;
Step A07: described apply in current preview figure size, obtain split position and split position before Data, update camera resolution abscissa according to the data got, apply and obtain in current preview figure size Take the data after split position, update camera resolution vertical coordinate according to the data got;
Step A08: described application is to camera resolution abscissa, camera resolution vertical coordinate and current screen Resolution calculate, obtain current difference;
Step A09: described application judges whether current difference is 0, is then to perform step A11, otherwise performs Step A10;
Step A10: described application judges that current difference, whether less than the first difference, is then according to current difference Update the first difference, refresh counter, return step A04;Otherwise refresh counter, returns step A04;
Step A11: described application judges that camera resolution abscissa and camera resolution vertical coordinate are the biggest In 0, it is then to perform step A12, otherwise terminates;
Step A12: described application using camera resolution abscissa and camera resolution vertical coordinate as parameter, Create the object of system coordinates point class as camera resolution.
Method the most according to claim 5, it is characterised in that described step A09 is particularly as follows: described The absolute value of the difference of the attribute x in the resolution of computation camera resolution abscissa and current screen, Calculate the absolute value of camera resolution vertical coordinate and the difference of the attribute y in the resolution of current screen, by two Secondary calculated absolute value is sued for peace, and obtains current difference.
Method the most according to claim 1, it is characterised in that described according to postrotational camera image And the position that scan box image is in described postrotational camera image, camera image after rotation obtains Before the scan box image corresponding with scan box, also include: described application according to current application father's layout, sweep Retouch frame layout and camera image, calculate scan box image position in described postrotational camera image.
Method the most according to claim 7, it is characterised in that described application is according to current application father's cloth Office, scan box layout and camera image, calculate scan box image position in described postrotational camera image Put, including:
Step B01: application obtains the distance between left side and the left side of current application father's layout of scan box layout As topology file scan box left summit abscissa, obtain top and current application father's layout of scan box layout Top between distance as topology file scan box left summit vertical coordinate, obtain the width of preview pane layout As topology file preview pane width;Obtain the height of preview pane layout as topology file preview pane height;
Step B02: apply according to topology file scan box left summit abscissa, topology file preview pane width and The height of camera image obtains the horizontal seat on the scan box image left summit in described postrotational camera image Mark, according to topology file scan box left summit vertical coordinate, topology file preview pane height and the width of camera image Degree obtains the vertical coordinate on the scan box image left summit in described postrotational camera image, according to default Topology file scan box width, the height of camera image and topology file preview pane width obtain scan box image Width in described postrotational camera image, according to default topology file scan box height, camera figure The width of picture and topology file preview pane height obtain scan box image in described postrotational camera image Highly.
Method the most according to claim 8, it is characterised in that described scan box image is in described rotation After camera image in the abscissa on left summit be that topology file scan box left summit abscissa is multiplied by camera figure The height of picture is again divided by topology file preview pane width;
The vertical coordinate on the described scan box image left summit in described postrotational camera image is topology file Scan box left summit vertical coordinate is multiplied by the width of camera image again divided by topology file preview pane height;
Described scan box image width in described postrotational camera image is default topology file scanning Width of frame is multiplied by the height of camera image again divided by topology file preview pane width;
Described scan box image height in described postrotational camera image is default topology file scanning Frame height is multiplied by the width of camera image again divided by topology file preview pane height.
Method the most according to claim 1, it is characterised in that described application is by described system phase The camera preview frame of machine obtains camera image, particularly as follows: the auto-focusing that described application arranges system camera returns Mediation preview is adjusted back, and applies and obtains camera image by the camera preview frame of described system camera.
11. methods according to claim 10, it is characterised in that described the automatic of system camera is set Focusing readjustment and preview are adjusted back, including:
Step S7-1: the auto-focusing callback object of application establishment system auto-focusing readjustment class, according to establishment Auto-focusing callback object arrange system camera auto-focusing readjustment;
Step S7-2: application establishment system preview readjustment class object;
Step S7-3: apply according to the preview readjustment class object created and camera object, system camera is set Preview is adjusted back.
12. methods according to claim 1, it is characterised in that described according to postrotational camera figure Picture and scan box image position in described postrotational camera image, obtain in camera image after rotation Take the scan box image corresponding with scan box particularly as follows: described application according to postrotational camera image wide high, The coordinate on the described scan box image left summit in described postrotational camera image and described scan box image Wide height in described postrotational camera image, obtains corresponding with scan box in camera image after rotation Scan box image.
13. methods according to claim 1, it is characterised in that described step S1 specifically includes:
Described application arranges the readjustment of interfacial level controller, and described application creates camera object;
Described application, according to the described camera object created, obtains Current camera parameter;
Described application, according to described camera object, starts the camera preview frame of system camera.
14. methods according to claim 1, it is characterised in that described described camera image is carried out Rotate particularly as follows: described camera image dextrorotation is turn 90 degrees by described application.
15. methods according to claim 1, it is characterised in that described step S3 specifically includes:
The decoding data of the described application scan box image to getting, it is judged that decoding is the most successful, is Then determine scanning Quick Response Code success, terminate, otherwise return step S2.
16. 1 kinds of devices scanning Quick Response Code, it is characterised in that including: start module, the first acquisition mould Block and decoder module;
Described startup module, is used for starting system camera;
Described first acquisition module, after starting described system camera when described startup module, by described The camera preview frame of system camera obtains camera image, is rotated by described camera image, after rotating Camera image and scan box image position in described postrotational camera image, camera after rotation Image obtains the scan box image corresponding with scan box;
Described decoder module, is decoded for the scan box image getting described first acquisition module.
17. devices according to claim 16, it is characterised in that also include judge module, described in sentence Disconnected module is for before described startup module activation system camera, it is judged that whether system camera exists;
Described startup module, specifically for after described judge module is judged to be, starts system camera.
18. devices according to claim 16, it is characterised in that also include: the second acquisition module; Described second acquisition module includes that the first acquisition submodule, the second acquisition submodule and first arrange submodule;
Described first obtains submodule for carrying out rotating it by described camera image when described first acquisition module Before, obtain the resolution of current screen;
Described second obtains submodule for obtaining with described in the preview graph size that described system camera is supported First obtains the immediate value of resolution of the current screen that submodule gets as camera resolution;
Described first arranges submodule for obtaining, according to described second, the described camera resolution that submodule gets Rate arranges camera image.
19. devices according to claim 18, it is characterised in that described first obtains submodule includes: First acquiring unit, the first creating unit, second acquisition unit and the second judging unit;
Described first acquiring unit, for the window services provided according to described system, obtains current application Forms manager object;
Described first creating unit, for the described forms manager got according to described first acquiring unit Object, creates the object of forms display class;
Described second acquisition unit, shows class for the described forms created according to described first creating unit Object, obtains the resolution of current screen;
Described second judging unit, for judging the resolution of current screen that described second acquisition unit gets Whether the value of the attribute x in rate is less than the value of attribute y, is then by the attribute x in the resolution of current screen The value of value and attribute y swap, determine the resolution getting current screen, otherwise determine and get The resolution of current screen.
20. devices according to claim 18, it is characterised in that described second obtains submodule includes: Initialization unit, the 3rd acquiring unit, the first cutting unit, the 3rd judging unit, the second creating unit, 4th acquiring unit, the first updating block, the first computing unit, the 4th judging unit, the 5th judging unit, 6th judging unit and the 3rd creating unit;
Described initialization unit, be used for initializing camera resolution abscissa, camera resolution vertical coordinate, One difference sum counter;
Described 3rd acquiring unit, for according to the second preset characters string, obtaining the object of template class;
Described first cutting unit, the object of the template class for getting according to described 3rd acquiring unit, It is preview graph size character string array by the preview graph sized divisions of Current camera support;
Described 3rd judging unit, for judging that whether the value of enumerator is more than preview graph size character string array In data amount check;
When described 3rd judging unit, described second creating unit, for judging that the value of enumerator is not more than preview During data amount check in figure size character string array, obtain and enumerator in preview graph size character string array Preview graph size character string corresponding to value, i.e. current preview figure size;
Described 4th acquiring unit, for obtaining what the 3rd preset characters string obtained in described second creating unit Position in current preview figure size is as split position;
Described first updating block, for obtaining in the current preview figure size that described second creating unit obtains Take the data before split position and split position, update camera resolution abscissa according to the data got, Apply in current preview figure size, obtain the data after split position, according to the data got more cenotype Machine resolution vertical coordinate;
Described first computing unit, for described first updating block is obtained camera resolution abscissa, The resolution of camera resolution vertical coordinate and current screen calculates, and obtains current difference;
Described 4th judging unit, is used for judging whether current difference is 0;
Described 5th judging unit, is used for when described 4th judging unit judges that current difference is not 0, Judge that current difference, whether less than the first difference, is to update the first difference, more New count according to current difference Device, triggers described 3rd judging unit and is operated;Otherwise refresh counter, triggers the described 3rd and judges list Unit is operated;
Described 6th judging unit, for when described 4th judging unit judges that current difference is 0, sentences Whether disconnected camera resolution abscissa and camera resolution vertical coordinate are all higher than 0;
Described 3rd creating unit, for judging that when described 3rd judging unit the value of enumerator is more than preview Data amount check in figure size character string array, or described 6th judging unit judges that camera resolution is horizontal When coordinate and camera resolution vertical coordinate are all higher than 0, sit so that camera resolution abscissa and camera resolution are vertical It is denoted as parameter, creates the object of system coordinates point class as camera resolution.
21. devices according to claim 20, it is characterised in that described first computing unit, specifically For calculating the absolute value of the attribute x in the camera resolution abscissa resolution with current screen, calculate phase The absolute value of the attribute y in the resolution of machine resolution vertical coordinate and current screen, calculated by twice Absolute value is sued for peace, and obtains current difference.
22. devices according to claim 16, it is characterised in that also include: the first computing module;
Described first computing module is used at described first acquisition module according to postrotational camera image and scanning Block diagram picture position in described postrotational camera image, obtains in camera image after rotation and scans Before the scan box image that frame is corresponding, according to current application father's layout, scan box layout and camera image, meter Calculate scan box image position in described postrotational camera image.
23. devices according to claim 22, it is characterised in that described first computing module includes: 5th acquiring unit and the second computing unit;
Described 5th acquiring unit, for obtaining the left side of scan box layout and the left side of current application father's layout Between distance as topology file scan box left summit abscissa, obtain the top of scan box layout with current Distance between the top of application father's layout, as topology file scan box left summit vertical coordinate, obtains preview pane The width of layout is as topology file preview pane width;The height obtaining preview pane layout is pre-as topology file Look at frame height;
Described second computing unit, for the topology file scan box got according to described 5th acquiring unit The height of left summit abscissa, topology file preview pane width and camera image obtains scan box image described The abscissa on the left summit in postrotational camera image, the layout got according to described 5th acquiring unit The width of file scan frame left summit vertical coordinate, topology file preview pane height and camera image obtains scan box The vertical coordinate on the image left summit in described postrotational camera image, according to default topology file scanning The topology file preview pane width that width of frame, the height of camera image and described 5th acquiring unit get obtains To scan box image width in described postrotational camera image, according to default topology file scan box Highly, the topology file preview pane height that the width of camera image and described 5th acquiring unit get obtains Scan box image height in described postrotational camera image.
24. devices according to claim 23, it is characterised in that described second computing unit, specifically For left for topology file scan box summit abscissa being multiplied by the height of camera image again divided by topology file preview Width of frame, obtains the abscissa on the described scan box image left summit in described postrotational camera image; The width that left for topology file scan box summit vertical coordinate is multiplied by camera image is high divided by topology file preview pane again Degree, obtains the vertical coordinate on the described scan box image left summit in described postrotational camera image;Will be pre- If topology file scan box width be multiplied by the height of camera image again divided by topology file preview pane width, To described scan box image width in described postrotational camera image;By default topology file scanning Frame height is multiplied by the width of camera image again divided by topology file preview pane height, obtains described scan box image Height in described postrotational camera image.
25. devices according to claim 16, it is characterised in that described first acquisition module includes Three obtain submodule, the first gyrator module and the 4th obtains submodule;
Described 3rd obtains submodule for when after the described startup module described system camera of startup, arranging system The auto-focusing readjustment of camera and preview are adjusted back;Camera figure is obtained by the camera preview frame of described system camera Picture;
The camera image that described first gyrator module gets for obtaining submodule by the described 3rd revolves Turn;
Described 4th obtains submodule, pre-for camera resolution and the described camera according to described system camera Look at the scan box position in frame, camera image after rotation obtains the scan box image corresponding with scan box.
26. devices according to claim 25, it is characterised in that the described 3rd obtains submodule includes: First unit, the 4th creating unit are set, second unit and the 6th acquiring unit are set;
Described first arranges unit, after starting described system camera when described startup module, creates system The auto-focusing callback object of auto-focusing readjustment class, the auto-focusing callback object according to creating arranges system The auto-focusing readjustment of camera;
Described 4th creating unit, for arranging unit and arrange the auto-focusing of system camera and return when described first After tune, create system preview readjustment class object;
Described second arranges unit, for according to described 4th creating unit create preview readjustment class object and Camera object, arranges the preview readjustment of system camera;
Described 6th acquiring unit, after when described second, the preview readjustment that unit arranges system camera is set, Camera image is obtained by the camera preview frame of described system camera.
27. devices according to claim 16, it is characterised in that described first acquisition module is specifically used After starting described system camera when described startup module, obtained by the camera preview frame of described system camera Camera image, rotates described camera image, according to postrotational camera image wide high, described in sweep Retouch the coordinate on the block diagram picture left summit in described postrotational camera image and described scan box image described Wide height in postrotational camera image, obtains the scanning corresponding with scan box in camera image after rotation Block diagram picture.
28. devices according to claim 16, it is characterised in that described startup module includes that interface is controlled System module, the first establishment submodule, the first promoter module and the 5th obtain submodule;
Described Interface Control submodule, for arranging the readjustment of interfacial level controller;
Described first creates submodule, after described Interface Control submodule arranges the readjustment of interfacial level controller, Create camera object;
Described 5th obtains submodule, for creating, according to described first, the described camera object that submodule creates, Obtain Current camera parameter;
Described first promoter module, for creating, according to described first, the described camera object that submodule creates, Start the camera preview frame of system camera.
29. devices according to claim 16, it is characterised in that described first acquisition module is specifically used After starting described system camera when described startup module, obtained by the camera preview frame of described system camera Camera image, turn 90 degrees described camera image dextrorotation, according to postrotational camera image and scan box Image position in described postrotational camera image, obtains and scan box in camera image after rotation Corresponding scan box image.
30. devices according to claim 16, it is characterised in that described decoder module, specifically for Decoding data to the scan box image that described first acquisition module gets, it is judged that decoding is the most successful, It is to determine scanning Quick Response Code success;
Described first acquisition module be additionally operable to when described decoder module be judged to no after, by described system camera Camera preview frame obtain camera image, described camera image is rotated, according to postrotational camera figure Picture and scan box image position in described postrotational camera image, obtain in camera image after rotation Take the scan box image corresponding with scan box.
CN201610244863.2A 2016-04-19 2016-04-19 Method and device for scanning two-dimensional code Pending CN105930757A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610244863.2A CN105930757A (en) 2016-04-19 2016-04-19 Method and device for scanning two-dimensional code

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610244863.2A CN105930757A (en) 2016-04-19 2016-04-19 Method and device for scanning two-dimensional code

Publications (1)

Publication Number Publication Date
CN105930757A true CN105930757A (en) 2016-09-07

Family

ID=56838492

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610244863.2A Pending CN105930757A (en) 2016-04-19 2016-04-19 Method and device for scanning two-dimensional code

Country Status (1)

Country Link
CN (1) CN105930757A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108712602A (en) * 2018-04-24 2018-10-26 Oppo广东移动通信有限公司 Camera control method, device, mobile terminal and storage medium
CN110678832A (en) * 2017-06-02 2020-01-10 苹果公司 Device, method and graphical user interface for processing data encoded in a machine-readable format
CN110971568A (en) * 2018-09-29 2020-04-07 零氪科技(北京)有限公司 Data docking device and method for closed system
CN111523340A (en) * 2019-02-02 2020-08-11 北京骑胜科技有限公司 Two-dimensional code identification method and device, electronic equipment and storage medium
CN116341586A (en) * 2023-02-27 2023-06-27 荣耀终端有限公司 Code scanning method, electronic equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1422068A (en) * 2001-11-23 2003-06-04 力捷电脑股份有限公司 Scanning method
CN105138946A (en) * 2015-10-09 2015-12-09 巴罗克(济南)生物技术有限公司 Datamatrix two-dimensional code identification method by means of intelligent mobile phone

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1422068A (en) * 2001-11-23 2003-06-04 力捷电脑股份有限公司 Scanning method
CN105138946A (en) * 2015-10-09 2015-12-09 巴罗克(济南)生物技术有限公司 Datamatrix two-dimensional code identification method by means of intelligent mobile phone

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
@雪@: "CodeForge", 《HTTP://WWW.CODEFORGE.COM/READ/255038/CAPTUREACTIVITY.JAVA_HTML》 *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110678832A (en) * 2017-06-02 2020-01-10 苹果公司 Device, method and graphical user interface for processing data encoded in a machine-readable format
CN108712602A (en) * 2018-04-24 2018-10-26 Oppo广东移动通信有限公司 Camera control method, device, mobile terminal and storage medium
CN110971568A (en) * 2018-09-29 2020-04-07 零氪科技(北京)有限公司 Data docking device and method for closed system
CN111523340A (en) * 2019-02-02 2020-08-11 北京骑胜科技有限公司 Two-dimensional code identification method and device, electronic equipment and storage medium
CN111523340B (en) * 2019-02-02 2023-05-05 北京骑胜科技有限公司 Two-dimensional code identification method and device, electronic equipment and storage medium
CN116341586A (en) * 2023-02-27 2023-06-27 荣耀终端有限公司 Code scanning method, electronic equipment and storage medium
CN116341586B (en) * 2023-02-27 2023-12-01 荣耀终端有限公司 Code scanning method, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN105930757A (en) Method and device for scanning two-dimensional code
US20210160556A1 (en) Method for enhancing resolution of streaming file
CN106155454B (en) Interface display method and device and electronic equipment
US7162080B2 (en) Graphic image re-encoding and distribution system and method
US20080246757A1 (en) 3D Image Generation and Display System
KR20040054416A (en) Method for processing still video image
CN113225606B (en) Video barrage processing method and device
CN103019537A (en) Image preview method and image preview device
CN111913633B (en) Method and device for realizing synchronous map interaction on spliced screen
CN104360847A (en) Method and equipment for processing image
CN108322658B (en) Photographing method and device
CN108108024B (en) Dynamic gesture obtaining method and device and display device
JP2023503764A (en) Unobstructed video overlay
KR101106910B1 (en) Method of visualizing a large still picture on a small-size display
CN113705156A (en) Character processing method and device
CN111913343A (en) Panoramic image display method and device
CN113238724B (en) Multi-zone combined screen projection method, device, equipment and storage medium
EP3143598A1 (en) Method of providing a digitally represented visual instruction from a specialist to a user in need of said visual instruction, and a system therefor
CN115588412A (en) Ink screen picture display method and device, terminal equipment and storage medium
CN114119639A (en) Single-image input self-supervision matting model training method, matting method and device
CN112822547A (en) Interface universe adaptive screen projection playing control method
CN111158618A (en) Method and equipment for displaying pattern based on mobile terminal
JP2004166237A (en) Method and system for generating image of moving object
CN109729286A (en) A kind of method that motion graphics are realized in superposition in video
KR102661488B1 (en) Servers, systems, methods and programs that provide special effect creation and 3d model creation services using generative ai models

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20160907

RJ01 Rejection of invention patent application after publication