Marcos
Published © MIT

Owlish: a smarter home monitoring system

Check who's snooping in your room when you're gone!

IntermediateFull instructions provided5 hours748
Owlish: a smarter home monitoring system

Story

Read more

Code

Code snippet #12

Plain text
cloudinary.config(
  cloud_name = "YOUR_CLOUDINARY_NAME",  
  api_key = "YOUR_CLOUDINARY_KEY",  
  api_secret = "YOUR_CLOUDINARY_SECRET"  
)

def upload_cloudinary(image_name):
    #We'll need an identifier to upload different intruders
    image_id = uuid.uuid1().int
    image_id = str(image_id)
    cloudinary.uploader.upload(image_name, public_id = image_id) #upload the captured image "detected"
    return (cloudinary.utils.cloudinary_url(image_id)) #access the uploaded image url via its public_id

Code snippet #13

Python
scan_bluetooth = Thread(target=rsl10_activate)
inference = Thread(target=start_picamera)
send_message = Thread(target=cloudinary_twilio_send)

if __name__ == '__main__':
    scan_bluetooth.start() #thread that scans for bluetooth low energy devices
    inference.start() # thread to start the inference once the RSL-10 BLE dev kit is connected
    send_message.start() #thread to check if an intruder is detected and then send the message over

Code snippet #14

Plain text
scan_bluetooth = Thread(target=rsl10_activate)
inference = Thread(target=start_picamera)
send_message = Thread(target=cloudinary_twilio_send)

if __name__ == '__main__':
    scan_bluetooth.start() #thread that scans for bluetooth low energy devices
    inference.start() # thread to start the inference once the RSL-10 BLE dev kit is connected
    send_message.start() #thread to check if an intruder is detected and then send the message over

Code snippet #5

Python
def detect_objects(interpreter, image, threshold):
  """Returns a list of detection results, each a dictionary of object info."""
  set_input_tensor(interpreter, image)
  interpreter.invoke()

  # Get all output details
  boxes = get_output_tensor(interpreter, 0)
  classes = get_output_tensor(interpreter, 1)
  scores = get_output_tensor(interpreter, 2)
  count = int(get_output_tensor(interpreter, 3))

  results = []
  for i in range(count):
    if scores[i] >= threshold:
      result = {
          'bounding_box': boxes[i],
          'class_id': classes[i],
          'score': scores[i]
      }
      image.save('intruder', "JPEG")
      results.append(result)
  return results

Code snippet #6

Plain text
def detect_objects(interpreter, image, threshold):
  """Returns a list of detection results, each a dictionary of object info."""
  set_input_tensor(interpreter, image)
  interpreter.invoke()

  # Get all output details
  boxes = get_output_tensor(interpreter, 0)
  classes = get_output_tensor(interpreter, 1)
  scores = get_output_tensor(interpreter, 2)
  count = int(get_output_tensor(interpreter, 3))

  results = []
  for i in range(count):
    if scores[i] >= threshold:
      result = {
          'bounding_box': boxes[i],
          'class_id': classes[i],
          'score': scores[i]
      }
      image.save('intruder', "JPEG")
      results.append(result)
  return results

Code snippet #7

Plain text
pi@raspberrypi:~ $ sudo hcitool lescan
LE Scan ...
4A:A1:30:61:7E:47 (unknown)
4A:24:DF:D4:2D:45 (unknown)
18:54:EA:40:A9:70 (unknown)
6C:EA:92:04:AE:49 (unknown)
60:C0:BF:28:65:C0 HB_BLE_Terminal

Code snippet #8

Plain text
pi@raspberrypi:~ $ sudo hcitool lescan
LE Scan ...
4A:A1:30:61:7E:47 (unknown)
4A:24:DF:D4:2D:45 (unknown)
18:54:EA:40:A9:70 (unknown)
6C:EA:92:04:AE:49 (unknown)
60:C0:BF:28:65:C0 HB_BLE_Terminal

Code snippet #9

Python
def rsl10_activate():
    while True:
        scanner = Scanner().withDelegate(ScanDelegate())
        devices = scanner.scan(3.0) #scan for 3 seconds and repeat
        for dev in devices:
            print ("Device %s (%s), RSSI=%d dB" % (dev.addr, dev.addrType, dev.rssi))
            if dev.addr == "60:c0:bf:28:65:c0":
               print("RSL-10 device found")
               global activate_status
               activate_status = not activate_status
               time.sleep(60)    

Code snippet #10

Plain text
def rsl10_activate():
    while True:
        scanner = Scanner().withDelegate(ScanDelegate())
        devices = scanner.scan(3.0) #scan for 3 seconds and repeat
        for dev in devices:
            print ("Device %s (%s), RSSI=%d dB" % (dev.addr, dev.addrType, dev.rssi))
            if dev.addr == "60:c0:bf:28:65:c0":
               print("RSL-10 device found")
               global activate_status
               activate_status = not activate_status
               time.sleep(60)    

Code snippet #11

Python
cloudinary.config(
  cloud_name = "YOUR_CLOUDINARY_NAME",  
  api_key = "YOUR_CLOUDINARY_KEY",  
  api_secret = "YOUR_CLOUDINARY_SECRET"  
)

def upload_cloudinary(image_name):
    #We'll need an identifier to upload different intruders
    image_id = uuid.uuid1().int
    image_id = str(image_id)
    cloudinary.uploader.upload(image_name, public_id = image_id) #upload the captured image "detected"
    return (cloudinary.utils.cloudinary_url(image_id)) #access the uploaded image url via its public_id

Github file

https://github.com/tensorflow/examples/blob/master/lite/examples/object_detection/raspberry_pi/README.md

Github

https://github.com/mcoscon/twilio_hack

Credits

Marcos

Marcos

4 projects • 3 followers
404

Comments