microsoft / moabian

Project Moab software stack
MIT License
23 stars 20 forks source link

Show a QR code to Moab to set wifi #12

Open scotstan opened 3 years ago

scotstan commented 3 years ago

If you don't have an ethernet cable and you don't have an HDMI monitor + keyboard, there's no way to configure Moab (easily) to put it on your wifi network.

An idea came up where one could "show" Moab's camera a QR code with wifi details.

keenbrowne commented 3 years ago

There are other projects that have tried to do this for linux: https://github.com/kokoye2007/wifi-qr for example. This site has more of a description of what's involved in the process: https://qifi.org/

scotstan commented 3 years ago

Got the code working after installing a few libraries:

sudo apt-get install libzbar0
pip3 install --user pyzbar imutils

And with this snippet:

from imutils.video import VideoStream
from pyzbar import pyzbar
import imutils
import time
import cv2

vs = VideoStream(usePiCamera=True).start() # For Pi Camera
time.sleep(0.25)

while True:
    frame = vs.read()
    frame = imutils.resize(frame, width=400)
    barcodes = pyzbar.decode(frame)
    for barcode in barcodes:
        print("found one")
        (x, y, w, h) = barcode.rect
        cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 0, 255), 2)
        barcodeData = barcode.data.decode("utf-8")
        barcodeType = barcode.type
        text = "{} ({})".format(barcodeData, barcodeType)
        print(text)

vs.stop()
scotstan commented 3 years ago

Data would go in /etc/wpa_supplicant/wpa_supplicant.conf

scotstan commented 3 years ago

Link for above: https://circuitdigest.com/microcontroller-projects/qr-code-scanner-using-raspberry-pi-and-opencv