tencent cloud

Image QR Code Recognition
Last updated: 2025-09-09 20:02:20
Image QR Code Recognition
Last updated: 2025-09-09 20:02:20

Feature Description

Cloud Infinite QR Code Recognition Function can identify the location and content of valid QR codes in images, output the text information (each QR code's corresponding URL or text) contained in the images, and add mosaic to the recognized QR codes.
Note:
This interface belongs to a GET request, uses a synchronous request method, and requires carrying a signature. For specific signature settings, please see Request Signature.

Authorization Description

When using with a sub-account, corresponding permissions must be granted. For COS permission details, please refer to COS action. For CI permission details, please refer to Cloud Infinite action.
During download, recognize that the action in the authorization policy is set to cos:GetObject, ci:CreateDetectQRcodeJob.
During upload, recognize: Set action to cos:PutObject in the authorization policy.

Service Activation

Using this feature requires enabling Cloud Infinite in advance and binding a bucket.
Using this feature requires enabling the AI Content Recognition service in advance via the console or API .

Use Limits

When using this API, please first confirm the relevant restrictions. For details, see Usage Limits.

Fee Description

This API is a paid service. Incurred fees will be charged by Cloud Infinite. For detailed billing instructions, see Content Recognition.

Request One: Identify during Upload

The request packet for recognizing QR codes during image upload matches the simple file upload API of COS. Just add the image processing parameter Pic-Operations to the request header and change the request Host to the domain name of Cloud Object Storage.

Request

PUT /<ObjectKey> HTTP/1.1
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
Date: GMT Date
Authorization: Auth String
Pic-Operations: <PicOperations>
Note:
COS simple file upload API. For details, see PUT Object document.
Authorization: Auth String. For details, see Request Signature document.

Request header

This API only uses common request headers. For details, see Common Request Headers documentation.

Request parameters

This API has no request parameters.

Request body

Pic-Operations is a json-formatted string. The specific parameters are as follows:
Parameter Name
Description
Type
Required or Not
is_pic_info
Whether to return original image information, 0 means no, 1 means yes, default is 0
Int
No
rules
Processing rules, one rule corresponds to one processing result (a maximum of five rules are currently supported). If left blank, image processing will not be performed.
Array
No
Each item in the rules (json array) has the following specific parameters:
Parameter Name
Description
Type
Required or Not
bucket
The destination bucket for storing results, with the format BucketName-APPID. If not specified, it defaults to the current bucket.
String
No
fileid
The file path name of the processing result. For example, if it starts with /, it will be stored in the specified folder; otherwise, it will be stored in the same directory as the original image file.
String
No
rule
process parameter, see Cloud Infinite image processing API. If processed with a specified style, start with style/, followed by the style name.
For example, if the style name is test, the rule field is style/test.
String
Yes
To use the QR Code Recognition Function, add the QR code recognition parameter (QRcode) in the rule. The relevant content is as follows:
QRcode/cover/<mode>
Sample parameter descriptions are as follows:
Parameter Name
Description
Type
Required or Not
cover
QR code override feature. Can be 0 or 1.
0 indicates that QR code overwrite is disabled.
1 indicates enabling QR code override
After the feature is enabled, it will overlay a mosaic on the recognized QR code. Default value is 0.
Int
No
bar-type
QR/barcode recognition feature: overlays a mosaic on recognized QR/barcodes. Value is 0, 1, or 2.
0 means all are recognized.
1. Means scanning QR code
2 means to scan barcode.
Default value 0.
Int
No
segment
Common slice switch parameter, specifies whether slicing is required, valid value:
0 (means no slicing)
1 (means slicing)
Default value 0. When slicing is required, the backend will perform slice recognition based on image dimensions.
Int
No
size
This parameter takes effect when segment is set to 1. The default value is 1000 pixels, with a value range of integers equal to or greater than 500. If the value specified by size is greater than the image pixel size, slicing will not be performed and direct recognition will be carried out.
Int
No

Response

Response Headers

This API only returns the public response header. For details, see Common Response Headers documentation.

Response Body

The specific data content of the response body is as follows:
Parameter Name
Type
Description
UploadResult
Container
Image information
UploadResult node content:
Parameter Name
Type
Description
OriginalInfo
Container
Image information
ProcessResults
Container
Image Processing result
Content of the OriginalInfo node
Node Name
Type
Description
Key
String
Original Image File Name
Location
String
image path
ImageInfo
Container
Original Image Information
Content of the ImageInfo node
Node Name
Type
Description
Format
String
Format
Width
Int
image width
Height
Int
image height
Quality
Int
image quality
Ave
String
dominant color of the image
Orientation
Int
image rotation angle
Process results within the ProcessResults node
Node Name
Type
Description
Object
Container
process result of each image
Content of the Object node
Node Name
Type
Description
Key
String
File Name
Location
String
image path
Format
String
image format
Width
Int
image width
Height
Int
image height
Size
Int
image size
Quality
Int
image quality
codeStatus
Int
QR code recognition result. 0 means no QR codes recognized, 1 means recognize QR code.
QRcodeInfo
Container
QR code recognition result, multiple possible
QRcodeInfo node content:
Node Name
Type
Description
codeUrl
String
Content of the QR code. May not be recognized.
codelocation
Container
Position coordinates of the QR code identified in the figure
codelocation node content:
Node Name
Type
Description
point
String
QR code coordinate point

Examples

Request

PUT /picture.jpg HTTP/1.1
Host: examplebucket-1250000000.cos.ap-chengdu.myqcloud.com
Date: Tue, 03 Apr 2018 09:06:15 GMT
Authorization:XXXXXXXXXXXX



Pic-Operations: {"is_pic_info":1,"rules":[{"fileid":"test.jpg","rule":" QRcode/cover/1"}]}
Content-Length: 64



[Object]

Response

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 645
Date: Tue, 03 Apr 2018 09:06:16 GMT
Status: 200 OK
x-cos-request-id: NWFjMzQ0MDZfOTBmYTUwXzZkZV8z****


<UploadResult>
<OriginalInfo>
<Key>picture.jpg</Key>
<Location>examplebucket-1250000000.cos.ap-chengdu.myqcloud.com/picture.jpg</Location>
<ImageInfo>
<Format>JPEG</Format>
<Width>640</Width>
<Height>427</Height>
<Quality>100</Quality>
<Ave>0xa18454</Ave>
<Orientation>1</Orientation>
</ImageInfo>
</OriginalInfo>
<ProcessResults>
<Object>
<Key>picture-2.jpg</Key>
<Location>examplebucket-1250000000.cos.ap-chengdu.myqcloud.com/picture-2.jpg</Location>
<Format>png</Format>
<Width>640</Width>
<Height>427</Height>
<Size>463092</Size>
<Quality>100</Quality>
<codeStatus>1</codeStatus>
<QRcodeInfo>
<CodeUrl>xxxxxxxxxxxxx</CodeUrl>
<CodeLocation>
<Point>100,100</Point>
<Point>100,200</Point>
<Point>200,200</Point>
<Point>200,100</Point>
</CodeLocation>
</QRcodeInfo>
<QRcodeInfo>
<CodeUrl>xxxxxxxxxxxxx</CodeUrl>
<CodeLocation>
<Point>1000,1000</Point>
<Point>1000,2000</Point>
<Point>2000,2000</Point>
<Point>2000,1000</Point>
</CodeLocation>
</QRcodeInfo>
</Object>
</ProcessResults>
</UploadResult>

Request Two: Identify during Download



Request

GET /<ObjectKey>?ci-process=QRcode&cover=<cover> HTTP/1.1
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
Date: <GMT Date>
Authorization: <Auth String>
Note:
Authorization: Auth String (See Request Signature document.)

Request header.

This API only uses common request headers. For details, see Common Request Headers documentation.

Request parameters.

Parameter Name
Description
Required or Not
Type
ObjectKey
object filename, for example folder/sample.jpg
Yes
String
ci-process
Wanxiang processing capability QR code recognition is fixed as QRcode
Yes
String
cover
QR code overlay feature, which overlays a mosaic on the recognized QR code. The value is 0 or 1. 0 means the QR code overlay is disabled, and 1 means it is enabled. Default value is 0.
No
Int

Request body.

This request has no request body.

Response

Response Headers

This API only returns the public response header. For details, see Common Response Headers documentation.

Response Body

The response body is returned as application/xml. An example including the complete node data is shown below:
<Response>
<CodeStatus>1</CodeStatus>
<QRcodeInfo>
<CodeUrl>xxxx</CodeUrl>
<CodeLocation>
<Point>xxx,xxx</Point>
<Point>xxx,xxx</Point>
<Point>xxx,xxx</Point>
<Point>xxx,xxx</Point>
</CodeLocation>
</QRcodeInfo>
<ResultImage>
base64-encoded image
</ResultImage>
</Response>
The data are as follows:
Node Name (Keyword)
Parent Node
Description
Type
Response
None.
Container to save results
Container
The content of the Response:
Node Name (Keyword)
Parent Node
Description
Type
CodeStatus
Response
QR code recognition result. 0 means no QR codes recognized, 1 means recognize QR code.
Int
QRcodeInfo
Response
QR code recognition result, multiple possible
Container
ResultImage
Response
Processed image base64 data, returned when request parameter cover is 1
String
QRcodeInfo node content:
Node Name (Keyword)
Parent Node
Description
Type
CodeUrl
QRcodeInfo
Content of the QR code. May not be recognized.
String
CodeLocation
QRcodeInfo
Position coordinates of the QR code identified in the figure
Container
CodeLocation node content:
Node Name (Keyword)
Parent Node
Description
Type
Point
CodeLocation
QR code coordinate point (X coordinate, Y coordinate)
String

Error Codes

This request returns common error responses and error codes. For more information, see Error Codes.

Examples

Request

GET /<ObjectKey>?ci-process=QRcode&cover=1 HTTP/1.1
Authorization: q-sign-algorithm=sha1&q-ak=**********************************&q-sign-time=1497530202;1497610202&q-key-time=1497530202;1497610202&q-header-list=&q-url-param-list=&q-signature=**************************************
Host: examplebucket-1250000000.cos.ap-beijing.myqcloud.com

Response

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 414641
Date: Thu, 15 Jun 2017 12:37:29 GMT
Server: tencent-ci
x-cos-request-id: NTk0MjdmODlfMjQ4OGY3XzYzYzhf****


<Response>
<CodeStatus>1</CodeStatus>
<QRcodeInfo>
<CodeUrl>xxxxxxxxxxxxx</CodeUrl>
<CodeLocation>
<Point>100,100</Point>
<Point>100,200</Point>
<Point>200,200</Point>
<Point>200,100</Point>
</CodeLocation>
</QRcodeInfo>
<QRcodeInfo>
<CodeUrl>xxxxxxxxxxxxx</CodeUrl>
<CodeLocation>
<Point>1000,1000</Point>
<Point>1000,2000</Point>
<Point>2000,2000</Point>
<Point>2000,1000</Point>
</CodeLocation>
</QRcodeInfo>
<ResultImage>
base64-encoded image
</ResultImage>
</Response>

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback