Skip to content

Instantly share code, notes, and snippets.

Avatar

Suad Anwar suadanwar

View GitHub Profile
@suadanwar
suadanwar / face_lock.py
Last active Nov 24, 2020
This sample code is for Unlock A Door with Face Recognition Using OpenCV on Raspberry Pi.
View face_lock.py
#! /usr/bin/python
# import the necessary packages
from imutils.video import VideoStream
from imutils.video import FPS
import face_recognition
import imutils
import pickle
import time
import cv2
@suadanwar
suadanwar / simple_alarm.ino
Last active Nov 30, 2020
This is sample code for Simple Alarm System Using Maker Nano's tutorial.
View simple_alarm.ino
#define SENSOR 3
#define PIEZO 8
#define NOTE_G5 784
#define NOTE_C6 1047
int Sound[] = {NOTE_G5, NOTE_C6};
int SoundNoteDurations[] = {12, 8};
#define playSound() playMelody(Sound, SoundNoteDurations, 2)
@suadanwar
suadanwar / face_rec.py
Created Nov 12, 2020
This is sample code for Face Recognition using OpenCV on Raspberry Pi 400.
View face_rec.py
#! /usr/bin/python
# import the necessary packages
from imutils.video import VideoStream
from imutils.video import FPS
import face_recognition
import imutils
import pickle
import time
import cv2
@suadanwar
suadanwar / template_matching.py
Last active Nov 5, 2020
This is sample code for template matching tutorial using OpenCV on Raspberry Pi
View template_matching.py
import cv2
import numpy as np
img = cv2.imread("Cover.jpg")
gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
template = cv2.imread("Raspberry Pi.jpg", 0)
w, h = template.shape[::-1]
count = 0
res = cv2.matchTemplate(gray_img, template, cv2.TM_CCORR_NORMED )
#methods = ['cv.TM_CCOEFF', 'cv.TM_CCOEFF_NORMED', 'cv.TM_CCORR','cv.TM_CCORR_NORMED', 'cv.TM_SQDIFF', 'cv.TM_SQDIFF_NORMED']
@suadanwar
suadanwar / Barometer_grove.ino
Created Oct 30, 2020
This sample code is for measuring surrounding air pressure's tutorial using Grove Air Pressure Sensor(BMP280)
View Barometer_grove.ino
#include "Seeed_BMP280.h"
#include <Wire.h>
#include <Arduino.h>
#include <U8x8lib.h>
U8X8_SSD1306_128X64_ALT0_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE);
BMP280 bmp280;
void setup() {
Serial.begin(9600);
@suadanwar
suadanwar / DHT_grove.ino
Last active Oct 22, 2020
This sample code is for Read Surrounding Temperature and Humidity using Grove All In One Beginner Kit for Arduino's tutorial.
View DHT_grove.ino
#include "DHT.h"
#include <Arduino.h>
#include <U8x8lib.h>
#define DHTPIN 3
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
U8X8_SSD1306_128X64_ALT0_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE);
#define LED 4
#define PIEZO 5
@suadanwar
suadanwar / video_telegram.py
Created Oct 16, 2020
This sample code is for Send video to telegram bot using Raspberry Pi tutorial.
View video_telegram.py
import telepot
from picamera import PiCamera
import RPi.GPIO as GPIO
import time
from time import sleep
import datetime
from telepot.loop import MessageLoop
from subprocess import call
@suadanwar
suadanwar / security_image.py
Created Oct 6, 2020
This sample code is for Raspberry Pi Security Camera with Motion Detector tutorial(image).
View security_image.py
from gpiozero import MotionSensor
from picamera import PiCamera
import time
from time import sleep
pir = MotionSensor(4)
camera = PiCamera()
camera.rotation = 180
while True:
@suadanwar
suadanwar / security_video.py
Last active Oct 6, 2020
This sample code is for Raspberry Pi Security Camera with Motion Detector tutorial.
View security_video.py
from gpiozero import MotionSensor
from picamera import PiCamera
import time
from time import sleep
pir = MotionSensor(4)
camera = PiCamera()
camera.rotation = 180
while True:
@suadanwar
suadanwar / camera.py
Created Oct 2, 2020
This sample code is for Getting Started with Raspberry Pi Camera(Record A Video).
View camera.py
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.rotation = 180
camera.start_preview(fullscreen = False, window = (1300,10,640,480))
camera.start_recording('/home/pi/Desktop/video.h264')
sleep(5)
camera.stop_recording()