Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. import http.client
  2. import cv2
  3. import numpy as np
  4. import sys
  5. import time
  6.  
  7. if len(sys.argv)>1:
  8. inputImage = cv2.imread(sys.argv[1])
  9. else:
  10. inputImage = cv2.imread("address.jpeg")
  11. # Display barcode and QR code location
  12. def display(im, bbox):
  13. n = len(bbox)
  14. for j in range(n):
  15. cv2.line(im, tuple(bbox[j][0]), tuple(bbox[ (j+1) % n][0]), (255,0,0), 3)
  16.  
  17. #cv2.imshow("Results", im) # Display results
  18. # Create a qrCodeDetector Object
  19. qrDecoder = cv2.QRCodeDetector()
  20. # Detect and decode the qrcode
  21. t = time.time()
  22. data,bbox,rectifiedImage = qrDecoder.detectAndDecode(inputImage)
  23. print("Time Taken for Detect and Decode : {:.3f} seconds".format(time.time() - t))
  24.  
  25. if len(data)>0:
  26. print("Decoded Data : {}".format(data))
  27. display(inputImage, bbox)
  28. rectifiedImage = np.uint8(rectifiedImage);
  29. # cv2.imshow("Rectified QRCode", rectifiedImage); #imshow sie sypie w opencv4
  30.  
  31. else:
  32. print("QR Code not detected")
  33. # cv2.imshow("Results", inputImage)
  34. cv2.imwrite("output.jpg",inputImage)
  35.  
  36. # w3w
  37. address=data
  38.  
  39.  
  40. import what3words
  41. from os import environ
  42.  
  43. api_key = '0I0IARIK'
  44. w3w = what3words.Geocoder(api_key)
  45. res = w3w.forward(address)
  46. print(res)
  47.  
  48. # 0I0IARIK
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement