I'm using the bottom camera of an AR Drone to detect a QR code in order for me to know the whereabouts of the drone on a chessboard. The drone hovers over the chessboard, where each single square is a QR code holding the position(e.g. A1, C5, E7, etc.). When I press a certain key, it scans the QR code and returns to me the position.
Right now, I would like to be able to detect a single QR code out of many. Since it is possible that the drone has multiple QR codes in sight. Because I need to know which exact square the drone is on, or at least the closest one(for example: 2/3 above A1 and 1/3 above A2 should result in A1). Here's the code I'm currently using:
#!/usr/bin/python
from sys import argv
import zbar
import Image
import cv2
class DetectQRCode(object):
@classmethod
def detect_qr(self, image):
# create a reader
scanner = zbar.ImageScanner()
# configure the reader
scanner.parse_config('enable')
# obtain image data
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY,dstCn=0)
pil = Image.fromarray(gray)
width, height = pil.size
raw = pil.tostring()
# wrap image data
image = zbar.Image(width, height, 'Y800', raw)
# scan the image for barcodes
scanner.scan(image)
# extract results
for symbol in image:
# do something useful with results
if symbol.data == "None":
return "Drone bevindt zich buiten het raster"
else:
return symbol.data
Can this be done using OpenCV, Python? Does zbar have something I could use?