-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCalibration.py
62 lines (50 loc) · 1.5 KB
/
Calibration.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Import necessary packages
import numpy as np
import cv2 as cv
import ar_markers as ar
#import qrtools
# from qrtools.qrtools import QR
# from ar_markers.marker import HammingMarker
# test_image = cv.imread("images/coordinateTransformDots4Perspective.jpg")
#
# markers = ar.detect_markers(test_image)
# print(test_image.shape)
# print(markers)
# for marker in markers:
# marker.highlite_marker(test_image)
#
# cv.imwrite('images/calibrationCoordinateTestDots4.jpg', test_image)
#
#
# Display barcode and QR code location
def display(im, bbox):
n = len(bbox)
for j in range(n):
cv.line(im, tuple(bbox[j][0]), tuple(bbox[(j + 1) % n][0]), (255, 0, 0), 3)
# Display results
cv.imshow("Results", im)
# qr = qrtools.QR()
# qr.decode("hooplah")
# creates the QR object
# my_QR = QR(data=u"hooplah")
#
# # encodes to a QR code
# my_QR.encode()
qr_image1 = cv.imread("images/qr_code_fullpage_test2.jpg")
qr_image2 = cv.imread("images/QRcodeTest1.jpg")
qr_image = cv.imread("images/qr_code_test8.jpg")
print(qr_image1.shape)
print(qr_image2.shape)
print(qr_image.shape)
qrDecoder = cv.QRCodeDetector()
data, bbox, rectifiedImage = qrDecoder.detectAndDecode(qr_image)
if len(data) > 0:
print("Decoded Data : {}".format(data))
display(qr_image, bbox)
rectifiedImage = np.uint8(rectifiedImage);
cv.imwrite("images/qr_code_test2_result.jpg", rectifiedImage);
else:
print("QR Code not detected")
cv.imwrite("images/qr_code_test2_result.jpg", qr_image)
cv.waitKey(0)
cv.destroyAllWindows()