tencent cloud

Cloud Infinite

Release Notes and Announcements
Release Notes
Announcements
Product Introduction
Product Overview
Product Strengths
Use Cases
Feature Overview
Regions and Domains
Specifications and Limits
Billing
Billing Overview
Billing Mode
Billable Items
Free Tier
Payment Overdue
Viewing Bill Details
FAQs
Getting Started
Registering and Logging In
Bind Bucket
Uploading and Processing File
Downloading and Deleting Images
Unbinding Buckets
Using CI via COS
Features
Image Processing
Media Processing
Content Moderation
AI Content Recognition
File Processing
Smart Voice
File processing
User Guide
Overview
Bucket Management
Smart Toolbox
Job and Workflow
Data Monitoring
Usage statistics
Use Cases
Copyright Protection Solutions
Image Processing Practices
Working with API Authorization Policies
Workflow Practices
API Documentation
API Overview
Structure
Common Request Headers
Common Response Headers
Activate Vast Service
Image Processing
AI-Based Content Recognition
Smart Audio
Media Processing
Content Moderation
Document Processing
File Processing
Job and Workflow
Cloud Virus Detection
Error Codes
Request Signature
SDK Documentation
SDK Overview
Android SDK
iOS SDK
COS Android SDK
C SDK
C++ SDK
.NET(C#) SDK
Go SDK
COS iOS SDK
Java SDK
JavaScript SDK
Node.js SDK
PHP SDK
Python SDK
Mini Program SDK
Personal Information Protection Policy for SDK
Security and Compliance
Permission ‍Management
FAQs
Basic Settings
Document Processing
Media Processing
Content Recognition
Smart Audio
Agreements
Service Level Agreement
Contact Us
Glossary

Image QR Code

PDF
Mode fokus
Ukuran font
Terakhir diperbarui: 2024-02-29 16:52:32

Overview

This document provides an overview of APIs and SDK code samples for image QR codes.
API
Description
QR code recognition
Recognizes the location and content of valid QR codes in an image, outputs the text information (URL or text) contained in the QR codes, and pixelates the recognized QR codes.
QR code generation
Generates QR codes or barcodes based on the specified text information (URL or text).

QR Code Recognition

Feature description

CI's QR code recognition feature recognizes the location and content of valid QR codes in an image, outputs the text information (URL or text) contained in the QR codes, and pixelates the recognized QR codes.

Method prototype

func (s *CIService) GetQRcode(ctx context.Context, name string, cover int, opt *ObjectGetOptions, id ...string) (*GetQRcodeResult, *Response, error)

Sample request 1: Recognizing during upload

opt := &cos.ObjectPutOptions{
nil,
&cos.ObjectPutHeaderOptions{
XOptionHeader: &http.Header{},
},
}
pic := &cos.PicOperations{
IsPicInfo: 1,
Rules: []cos.PicOperationsRules{
{
FileId: "format.jpg",
Rule: "QRcode/cover/1",
},
},
}
opt.XOptionHeader.Add("Pic-Operations", cos.EncodePicOperations(pic))
name := "test.jpg"
filepath := "./QRcode.jpg"
res, _, err := c.CI.PutFromFile(context.Background(), name, filepath, opt)

Sample request 2: Recognizing during download

name := "test.jpg"
res, _, err := c.CI.GetQRcode(context.Background(), name, 1, nil)

Parameter description

Parameter
Description
Type
Required
cover
Pixelates the recognized QR code. Valid values: 0 (no), 1 (yes). Default value: 0.
int
Yes

Response description

The returned result of recognition during download is as follows:
type GetQRcodeResult struct {
CodeStatus int
QRcodeInfo *QRcodeInfo
ResultImage string
}
type QRcodeInfo struct {
CodeUrl string
CodeLocation *CodeLocation
}
type CodeLocation struct {
Point []string
}
Parameter
Description
Type
CodeStatus
Whether QR codes are recognized. 0: No; 1: Yes.
int
QRcodeInfo
Recognized QR code. There may be multiple ones.
Struct
ResultImage
Base64-encoded image data, which is returned if the request parameter cover is 1.
string
CodeUrl
QR code content. Content may not be recognized.
string
CodeLocation
Location coordinates of the QR code recognized in the image.
Struct
Point
QR code coordinates (X,Y).
Array

QR Code Generation

Feature description

CI's QR code generation feature generates QR codes or barcodes based on the specified text information (URL or text).

Method prototype

func (s *CIService) GenerateQRcode(ctx context.Context, opt *GenerateQRcodeOptions) (*GenerateQRcodeResult, *Response, error)

func (s *CIService) GenerateQRcodeToFile(ctx context.Context, filePath string, opt *GenerateQRcodeOptions) (*GenerateQRcodeResult, *Response, error)

Sample request

opt := &cos.GenerateQRcodeOptions{
QRcodeContent: "<https://www.example.com>"
Mode: 0,
Width: 200,
}
// Case 1. Generate a QR code
res, _, err := c.CI.GenerateQRcode(context.Background(), opt)

// Case 2. Generate a QR code and save it as a file
filepath := "example.jpg"
res, _, err := c.CI.GenerateQRcodeToFile(context.Background(), filepath, opt)

Parameter description

type GenerateQRcodeOptions struct {
QRcodeContent string
Mode int
Width int
}
Parameter
Description
Type
QRcodeContent
Recognizable QR code text information
string
Mode
Type of the QR code to be generated. Valid values: 0 (QR code), 1 (barcode). Default value: 0.
int
Width
Width of the QR code or barcode to be generated. The height will be compressed proportionally.
int

Response description

type GenerateQRcodeResult struct {
ResultImage string
}
Parameter
Description
Type
ResultImage
Base64-encoded QR code image data
string

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan