In my UiPath Studio, ZXing.Net (0.16.11) is installed. I need to use the Invoke Code activity to achieve QR code recognition in images. I have created variables: imagePath (String) – input image path, and resultText (String) – output recognition result.
After entering the following code in Edit Code:
vb
Imports ZXing
Imports System.Drawing
Imports System.IO
Try
Dim bitmap As New Bitmap(imagePath)
Dim reader As New BarcodeReader
reader.Options.PossibleFormats = New List(Of BarcodeFormat) From {BarcodeFormat.QR_CODE}
reader.Options.TryHarder = True
reader.AutoRotate = True
Dim result As Result = reader.Decode(bitmap)
If result IsNot Nothing Then
resultText = result.Text
Else
resultText = “no barcode”
End If
bitmap.Dispose()
Catch ex As Exception
resultText = "failure: " & ex.Message
End Try
The following errors occurred:
No compiled code to run
error BC30024: Statement is not valid inside a method. At line 0
error BC30024: Statement is not valid inside a method. At line 1
error BC30024: Statement is not valid inside a method. At line 2
error BC30002: Type ‘BarcodeReader’ is not defined. At line 5
error BC30002: Type ‘BarcodeFormat’ is not defined. At line 6
error BC30451: ‘BarcodeFormat’ is not declared. It may be inaccessible due to its protection level. At line 6
error BC30002: Type ‘Result’ is not defined. At line 9
Variable ‘BarcodeReader’ is missing. Please use Data Manager to recreate it.
Thanks for your reply,Yoichi.
I succeeded to use Barcode activities package to decode QRcode but failed to run the automation in Assistant due to lower dependence for automation Acitivities.
Do you have any error? Does it fail on another machine?
If it fails to install necessary libraries, adding the following feed’s URL may solve this issue.