Using computer vision can be very useful in many situations it is designed for. In May 2022, just a few weeks after a devastating mass shooting, I was pissed off and wanted to find ways to help save lives in an active threat situation. 1
Machine Leaning Model Handgun Detection
>>>
How it works:
And yup, that works. But not without jumping through a few hoops:
#include opencv2/opencv.hpp #include opencv2/highgui/highgui.hpp
#include opencv2/imgproc/imgproc.hpp
#include iostream
#include opencv2/objdetect/objdetect.hpp
using namespace std;
using namespace cv;
void VideoStream() {
CascadeClassifier firearm_cascade;
firearm_cascade.load("/Users/zximy/Desktop/Stage1Firearm.xml"); /* Haar Cascade file */
String url = "http://192.168.1.118/640x480.jpg";
namedWindow("SCANNING AREA", WINDOW_AUTOSIZE);
while (true) {
VideoCapture videoResponse(url);
Mat videostream;
videoResponse >> videostream;
Mat gray;
cvtColor(videostream, gray, COLOR_BGR2GRAY);
vector gundetected;
firearm_cascade.detectMultiScale(gray, gundetected, 12, 26);
for (const Rect& rect : gundetected) {
rectangle(videostream, rect, Scalar(0, 0, 255), 3);
}
imshow("Scanning", videostream);
char key = waitKey(5);
if (key == 'q') {
break;
}
}
}
int main() {
VideoStream();
return 0;
}
For now it works well enough - lets build GuardianSafe. Type shit.
Rest in peace to all the lives lost in the Uvalde shooting. It was surreal sitting at my high school graduation just a few weeks after the shooting, knowing an entire generation of young souls took rounds from high-caliber rifle. That bastard shooter tortured those kids to death. Burn in hell, Salvador Ramos.
I got into angular pretty soon after I started programming and boy did it fuck with my brain. So much black magic. I haven 't done much frontend stuff since and want to get into that again - so yeah& Prepare for yet another framework. I 'm sorry world.
For more info, check e.g. OpenCv Documentation
https://unix.stackexchange.com/questions/366797/grep-slow-to-exit-after-finding-match - so that 's why pipes sometimes seem to get "stuck "- never thought about how things work. TIL.