-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from CornellDataScience/pre-commit
Replace clang-format scripts with pre-commit hooks
- Loading branch information
Showing
17 changed files
with
108 additions
and
141 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: pre-commit | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v3 | ||
- uses: pre-commit/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
- id: check-added-large-files | ||
- id: check-xml | ||
- repo: https://github.com/pre-commit/mirrors-clang-format | ||
rev: 'v17.0.6' # Use the sha / tag you want to point at | ||
hooks: | ||
- id: clang-format | ||
- repo: https://github.com/psf/black | ||
rev: 22.10.0 | ||
hooks: | ||
- id: black |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ def preprocess_image(filename): | |
|
||
return img | ||
|
||
|
||
# load the model | ||
siamese = SiameseNetwork( | ||
seed=seed, | ||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,17 @@ | ||
import os | ||
from twilio.rest import Client | ||
import os | ||
from twilio.rest import Client | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
|
||
account_sid = os.getenv('TWILIO_ACCOUNT_SID') | ||
auth_token = os.getenv('TWILIO_AUTH_TOKEN') | ||
account_sid = os.getenv("TWILIO_ACCOUNT_SID") | ||
auth_token = os.getenv("TWILIO_AUTH_TOKEN") | ||
|
||
from_number = "+18886815709" | ||
to_number = "+19788814542" | ||
|
||
from_number = '+18886815709' | ||
to_number = '+19788814542' | ||
|
||
def send_message(intruder_detected): | ||
msg = "Intruder Alert!" if intruder_detected else "Welcome!" | ||
client = Client(account_sid, auth_token) | ||
message = client.messages.create( | ||
body=msg, | ||
from_=from_number, | ||
to=to_number) | ||
|
||
message = client.messages.create(body=msg, from_=from_number, to=to_number) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ David_Han 1 5 | |
David_Han 2 6 | ||
David_Han 3 7 | ||
David_Han 4 8 | ||
David_Han 5 10 | ||
David_Han 5 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,42 @@ | ||
#include <opencv2/opencv.hpp> | ||
#include <iostream> | ||
#include <opencv2/opencv.hpp> | ||
|
||
const double MIN_CONTOUR_SIZE = 3000; // Adjust this threshold as needed | ||
|
||
bool detect_motion(std::string im_path1, std::string im_path2) | ||
{ | ||
|
||
// load images | ||
cv::Mat image1 = cv::imread(im_path1); | ||
cv::Mat image2 = cv::imread(im_path2); | ||
|
||
// preprocess | ||
cv::Mat gray1, gray2; | ||
|
||
cv::cvtColor(image1, gray1, cv::COLOR_BGR2GRAY); | ||
cv::cvtColor(image2, gray2, cv::COLOR_BGR2GRAY); | ||
cv::GaussianBlur(gray1, gray1, cv::Size(21, 21), 0); | ||
cv::GaussianBlur(gray2, gray2, cv::Size(21, 21), 0); | ||
|
||
cv::Mat diff; | ||
cv::absdiff(gray1, gray2, diff); | ||
|
||
cv::Mat thresh; | ||
cv::threshold(diff, thresh, 25, 255, cv::THRESH_BINARY); | ||
|
||
std::vector<std::vector<cv::Point>> contours; | ||
cv::findContours(thresh, contours, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE); | ||
|
||
for (int i = 0; i < contours.size(); i++) | ||
{ | ||
cv::drawContours(image2, contours, i, cv::Scalar(0, 255, 0), 2); | ||
} | ||
bool detect_motion(std::string im_path1, std::string im_path2) { | ||
|
||
// load images | ||
cv::Mat image1 = cv::imread(im_path1); | ||
cv::Mat image2 = cv::imread(im_path2); | ||
|
||
// preprocess | ||
cv::Mat gray1, gray2; | ||
|
||
cv::cvtColor(image1, gray1, cv::COLOR_BGR2GRAY); | ||
cv::cvtColor(image2, gray2, cv::COLOR_BGR2GRAY); | ||
cv::GaussianBlur(gray1, gray1, cv::Size(21, 21), 0); | ||
cv::GaussianBlur(gray2, gray2, cv::Size(21, 21), 0); | ||
|
||
cv::Mat diff; | ||
cv::absdiff(gray1, gray2, diff); | ||
|
||
cv::Mat thresh; | ||
cv::threshold(diff, thresh, 25, 255, cv::THRESH_BINARY); | ||
|
||
std::vector<std::vector<cv::Point>> contours; | ||
cv::findContours(thresh, contours, cv::RETR_EXTERNAL, | ||
cv::CHAIN_APPROX_SIMPLE); | ||
|
||
for (int i = 0; i < contours.size(); i++) { | ||
cv::drawContours(image2, contours, i, cv::Scalar(0, 255, 0), 2); | ||
} | ||
|
||
bool motionDetected = false; | ||
for (int i = 0; i < contours.size(); i++) | ||
{ | ||
if (cv::contourArea(contours[i]) > MIN_CONTOUR_SIZE) | ||
{ | ||
motionDetected = true; | ||
break; | ||
} | ||
bool motionDetected = false; | ||
for (int i = 0; i < contours.size(); i++) { | ||
if (cv::contourArea(contours[i]) > MIN_CONTOUR_SIZE) { | ||
motionDetected = true; | ||
break; | ||
} | ||
return motionDetected; | ||
} | ||
return motionDetected; | ||
} |