Paano bumuo ng isang Barcode scanner App gamit ang Java SDK. Ipatupad ang mga kakayahan ng QR scan sa iyong Web, Mobile at Desktop Applications.

Barcode scanner

I-scan ang barcode online | QR code scanner

Sa artikulong ito, tatalakayin natin ang mga detalye kung paano bumuo ng isang Barcode scanner at isang QR code scanner app gamit ang Java REST API. Naiintindihan namin na sa mabilis na ekonomiya ngayon, ang mga Barcode ay isang mahalaga at mabubuhay na solusyon para sa mga vendor at merchant para sa pag-iimbak ng mga detalye ng produkto. Sa paglipas ng mga taon, napatunayan na sila ay isang mahalaga at mabubuhay na pagpipilian para sa mga negosyo. Sila ay lubos na napabuti ang kahusayan at nabawasan ang overhead. Ang mga barcode ay parehong cost-effective at maaasahan. Kabilang sa iba pang mga benepisyo ng paggamit ng BarCode, na tinukoy sa ibaba ay ilan pang mga pakinabang ng paggamit ng mga ito

  • Tinatanggal ng mga barcode ang posibilidad ng pagkakamali ng tao
  • Ang paggamit ng barcode system ay nagpapababa ng oras ng pagsasanay ng empleyado
  • Ang mga barcode ay lubhang maraming nalalaman at maaaring gamitin para sa anumang uri ng kinakailangang pangongolekta ng data
  • Pinapagana nila ang tumpak na kontrol sa imbentaryo, at samakatuwid ang kontrol ng Imbentaryo ay nagpapabuti
  • Higit pa rito, ang mga Barcode ay nagbibigay ng mas mahusay na data ie isang barcode ay maaaring magbigay ng imbentaryo at mga detalye ng pagpepresyo

Nauukol sa lahat ng naturang feature, binibigyang-lakas ng Aspose.BarCode Cloud Java SDK ang mga developer ng Java na gumawa at mag-scan ng Barcode online gamit ang wikang Java. Katulad ng aming iba pang Cloud API, hinihiling sa iyo ng Aspose.BarCode Cloud Java SDK na magparehistro ng account sa Cloud Dashboard. Kung nakapagrehistro ka na ng account, maaari mo itong ipagpatuloy. Kapag naihanda mo na ang iyong account, mahusay mong gamitin ang Mga Serbisyo sa Cloud sa pamamagitan ng AppKey at AppSID.

Maaari mong isaalang-alang ang paggamit ng Aspose Cloud storage o, gumamit ng anumang mga third-party na serbisyo ng cloud storage para sa pag-iimbak at pagkuha ng file.

Mga Sinusuportahang Barcode Symbology

Sinusuportahan ng SDK ang maraming simbolo ng Barcode (higit sa 60) gaya ng EAN, UPC, Codabar, PDF417, QR, MicroQR, Postnet, Planet, RM4SCC, atbp. Makukuha mo rin ang opsyong i-load ang umiiral nang impormasyon ng BarCode at i-save ang output sa sikat na larawan mga format, gaya ng JPEG, PNG, GIF, BMP, TIFF, EMF, WMF, SVG, EXIF, at ICON. Para sa kumpletong listahan ng mga sinusuportahang simbolo, pakibisita ang Aspose.BarCode Cloud Java SDK.

Bumuo ng Barcode

Ang SDK ay nag-aalok sa iyo na lumikha ng mga Linear, 2D, at postal na mga imahe ng barcode sa maraming mga format. Maaari mong tukuyin ang mga katangian ng imahe ng barcode tulad ng lapad ng larawan, taas, istilo ng hangganan, at format ng imahe ng output. Maaari mo ring tukuyin ang uri ng barcode at mga katangian ng teksto tulad ng lokasyon ng teksto at mga estilo ng font ayon sa iyong mga kinakailangan sa aplikasyon. Nagbibigay din ito ng mga kakayahan upang itakda ang taas ng mga bar at paikutin ang mga imahe ng barcode sa isang anggulo.

Ang sumusunod na halimbawa ay nagpapakita ng mga hakbang sa paggawa ng Code39Standard Barcode, na inilagay sa Top-Center alignment ng page. Ang kulay ng text ay tinukoy bilang Navy, Horizontal, at Vertical na resolution ay tinukoy bilang 200. Ang BarColor ay tinukoy bilang Orange, ang kulay ng background ay nakatakda bilang pilak at ang format ng output ay JPEG na format.

Bago kami magpatuloy, inirerekumenda namin na bisitahin mo ang sumusunod na link dahil kailangan ang isang JWT token kapag ina-access ang API gamit ang cURL command.

kulot

curl -X PUT "https://api.aspose.cloud/v3.0/barcode/MySample.jpeg/generate?Type=Code39Standard&Text=BarCode%20processing&TextLocation=Above&TextAlignment=Center&TextColor=Navy&FontSizeMode=Auto&Resolution=200&ResolutionX=200&BackColor=silver&BarColor=Orange&BorderColor=Blue&format=jpeg" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>"

Humiling ng URL

https://api.aspose.cloud/v3.0/barcode/MySample.jpeg/generate?Type=Code39Standard&Text=BarCode%20processing&TextLocation=Above&TextAlignment=Center&TextColor=Navy&FontSizeMode=Auto&Resolution=200&ResolutionX=200&BackColor=silver&BarColor=Orange&BorderColor=Blue&format=jpeg

Java

ApiClient client = new ApiClient(
"App SID from https://dashboard.aspose.cloud/#/apps",
"App Key from https://dashboard.aspose.cloud/#/apps");
		        
com.aspose.barcode.cloud.api.BarcodeApi api = new com.aspose.barcode.cloud.api.BarcodeApi(client);
String name = "MySample.jpeg";
String type = com.aspose.barcode.cloud.model.EncodeBarcodeType.CODE39STANDARD.getValue();	
String text = "Barcode processing API"; // String | Text to encode.
String twoDDisplayText = null;
String textLocation = com.aspose.barcode.cloud.model.CodeLocation.ABOVE.getValue();
String textAlignment = com.aspose.barcode.cloud.model.TextAlignment.CENTER.getValue();
String textColor = "Navy";
String fontSizeMode = com.aspose.barcode.cloud.model.FontMode.AUTO.getValue();
int resolution = 200;
double resolutionX = 200;
double resolutionY = 200;
String barColor = "Orange";
String format = "JPEG";
		        
try {
com.aspose.barcode.cloud.model.ResultImageInfo result = api.putBarcodeGenerateFile(
    name, 
		type, 
		text, 
		twoDDisplayText, 
		textLocation, 
		textAlignment, 
		textColor, 
		fontSizeMode, 
		(double) resolution, 
		resolutionX, 
		resolutionY, 
		null, 
		null, 
		null, 
		null, 
		null, 
		null, 
		null, 
		null, 
		"Silver", 
		barColor, 
		"Blue",
		null, 
		null, 
		true, 
		null, 
		null, 
		null, 
		null, 
		null, 
		null, 
		null, 
		null, 
		null, 
		null,
		format);
		            
  System.out.println(result);
	} catch (ApiException e) {
  System.err.println("Exception when calling BarcodeApi#PutBarcodeGenerateFile");
	e.printStackTrace();
}
Online na barcode scanner

Larawan 1:- Nagresultang preview ng BarCode.

Online na Barcode Reader

QR scan

Larawan 2: QR code scanner

May kakayahan din ang Cloud API na kilalanin ang impormasyon mula sa mga umiiral nang barcode. Makukuha mo ang opsyong tukuyin ang mga detalye ng uri ng Barcode para sa mabilisang pagkuha o hayaang awtomatikong matukoy ng API ang uri. Maaari mo ring tukuyin ang mga detalye ng ChecksumValidation, DetectEncoding, o hayaan ang API na matukoy ang mga ito sa runtime.

kulot

curl -X POST "https://api.aspose.cloud/v3.0/barcode/recognize?Type=all&DetectEncoding=true" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>" \
-H  "Content-Type: multipart/form-data" \
-H  "x-aspose-client: Containerize.Swagger" -d {"image":{}}

Humiling ng URL

https://api.aspose.cloud/v3.0/barcode/recognize?Type=all&DetectEncoding=true

Java

// Para sa kumpletong mga halimbawa at data file, mangyaring pumunta sa https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-java/

String type = null;
String checksumValidation = ChecksumValidation.OFF.toString();
Boolean detectEncoding = null;
String preset = PresetType.HIGHPERFORMANCE.toString();

Integer rectX = null;
Integer rectY = null;
Integer rectWidth = null;
Integer rectHeight = null;
Boolean stripFNC = null;
Integer timeout = null;
Integer medianSmoothingWindowSize = null;
Boolean allowMedianSmoothing = null;
Boolean allowComplexBackground = null;
Boolean allowDatamatrixIndustrialBarcodes = null;
Boolean allowDecreasedImage = null;
Boolean allowDetectScanGap = null;
Boolean allowIncorrectBarcodes = null;
Boolean allowInvertImage = null;
Boolean allowMicroWhiteSpotsRemoving = null;
Boolean allowOneDFastBarcodesDetector = null;
Boolean allowOneDWipedBarsRestoration = null;
Boolean allowQRMicroQrRestoration = null;
Boolean allowRegularImage = null;
Boolean allowSaltAndPepperFiltering = null;
Boolean allowWhiteSpotsRemoving = null;
Double regionLikelihoodThresholdPercent = null;
List<Integer> scanWindowSizes = null;
Double similarity = null;
Boolean skipDiagonalSearch = null;
String australianPostEncodingTable = null;
String rectangleRegion = null;
String url = null;

Path currentRelativePath = Paths.get("");
String currentPath = currentRelativePath.toAbsolutePath().toString();
Path filePath = Paths.get(currentPath, "data", "sample.png");

File image = new File(String.valueOf(filePath));

BarcodeResponseList response = 
   	 api.postBarcodeRecognizeFromUrlOrContent( 
      		type,checksumValidation,detectEncoding,preset,rectX,rectY,rectWidth,rectHeight,
      		stripFNC,timeout,medianSmoothingWindowSize,allowMedianSmoothing,allowComplexBackground,
      		allowDatamatrixIndustrialBarcodes,allowDecreasedImage,allowDetectScanGap,
		allowIncorrectBarcodes,allowInvertImage,allowMicroWhiteSpotsRemoving,allowOneDFastBarcodesDetector,
      		allowOneDWipedBarsRestoration,allowQRMicroQrRestoration,allowRegularImage,allowSaltAndPepperFiltering,
      		allowWhiteSpotsRemoving,regionLikelihoodThresholdPercent,scanWindowSizes,similarity,skipDiagonalSearch,
      		australianPostEncodingTable,rectangleRegion,url,image);

assertNotNull(response);
assertFalse(response.getBarcodes().isEmpty());

BarcodeResponse barcode = response.getBarcodes().get(0);
assertEquals(DecodeBarcodeType.CODE11.getValue(), barcode.getType());
assertEquals("1234567812", barcode.getBarcodeValue());
2d barcode

Larawan 3:- 2D na preview ng barcode.

Kung patakbuhin mo ang code sa itaas sa tinukoy na imahe sa itaas, ire-render ng Response body ang output bilang

Katawan ng pagtugon

{  "barcodes":  [  {  "barcodeValue":  "12345678",  "type":  "Code39Standard",  "region":  [  {  "x":  **28**,  "y":  **3**  },  {  "x":  **222**,  "y":  **3**  },  {  "x":  **222**,  "y":  **74**  },  {  "x":  **28**,  "y":  **74**  }  ],  "checksum":  ""  }  ]  }

Konklusyon

Sa artikulong ito, natutunan namin ang mga hakbang kung paano bumuo ng Barcode scanner App gamit ang Java REST API. Katulad nito, binibigyang-daan ka rin ng API na magpatupad ng QR code reader mula sa image file. Bukod sa paggamit ng Java SDK, nakakakuha din kami ng opsyon na mag-scan ng barcode online gamit ang mga cURL command. Walang karagdagang pag-download o pag-install ng software ang kinakailangan. Kung sakaling makatagpo ka ng anumang mga isyu habang ginagamit ang API, mangyaring huwag mag-atubiling makipag-ugnayan sa amin sa pamamagitan ng free product support forum.

Mga Kaugnay na Artikulo

Inirerekomenda din namin ang pagbisita sa mga sumusunod na link upang matuto nang higit pa tungkol sa: