Skip to content

Commit 5174150

Browse files
author
MitCodes
authored
Add files via upload
1 parent e66929d commit 5174150

File tree

3 files changed

+125
-0
lines changed

3 files changed

+125
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
[
2+
{
3+
"id": "28cc2528.992c5a",
4+
"type": "bigexec",
5+
"z": "3ebfe993.c2a2ce",
6+
"name": "",
7+
"command": "python fire_detection.py",
8+
"commandArgs": "",
9+
"minError": 1,
10+
"minWarning": 1,
11+
"cwd": "C:/Users/Niladri/Code-setup/Deep Learning/real-time-object-detection",
12+
"shell": "",
13+
"extraArgumentProperty": "",
14+
"envProperty": "",
15+
"format": "utf8",
16+
"limiter": true,
17+
"payloadIs": "triggerNoStdin",
18+
"x": 368,
19+
"y": 1396.5,
20+
"wires": [
21+
[
22+
"4327a072.cd7a98"
23+
],
24+
[],
25+
[]
26+
]
27+
},
28+
{
29+
"id": "4327a072.cd7a98",
30+
"type": "ui_audio",
31+
"z": "3ebfe993.c2a2ce",
32+
"name": "",
33+
"group": "9edc3884.c8a378",
34+
"voice": "en-GB",
35+
"always": "",
36+
"x": 551,
37+
"y": 1392,
38+
"wires": []
39+
},
40+
{
41+
"id": "6686278e.e10e",
42+
"type": "ui_button",
43+
"z": "3ebfe993.c2a2ce",
44+
"name": "Start",
45+
"group": "9edc3884.c8a378",
46+
"order": 0,
47+
"width": "4",
48+
"height": "2",
49+
"passthru": false,
50+
"label": "Camera",
51+
"color": "",
52+
"bgcolor": "",
53+
"icon": "",
54+
"payload": "",
55+
"payloadType": "date",
56+
"topic": "",
57+
"x": 198,
58+
"y": 1407,
59+
"wires": [
60+
[
61+
"28cc2528.992c5a"
62+
]
63+
]
64+
},
65+
{
66+
"id": "9edc3884.c8a378",
67+
"type": "ui_group",
68+
"z": "",
69+
"name": "Detection",
70+
"tab": "d0c88fd3.4eef38",
71+
"order": 1,
72+
"disp": true,
73+
"width": "11"
74+
},
75+
{
76+
"id": "d0c88fd3.4eef38",
77+
"type": "ui_tab",
78+
"z": "",
79+
"name": "Parking",
80+
"icon": "dashboard",
81+
"order": 1
82+
}
83+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Fire-detection-using-Python
2+
3+
This code setup is used in Raspberry Pi which has OpenCV installed in it. The aim of the project is to detect fire from any CCTV camera or any USB camera without using any sensor.
4+
5+
Working:
6+
-------
7+
The USB camera is connecetd with RPi, as soon as any flame is detected it prints message as "Fire Detected". This message is than fed to Node-red which is running on RPi and reply back with a audio message "Fire Detected". We can also use HTTP Post to send the message to external server.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import cv2
2+
import numpy as np
3+
4+
#video_file = "video_1.mp4"
5+
video = cv2.VideoCapture(0)
6+
7+
while True:
8+
(grabbed, frame) = video.read()
9+
if not grabbed:
10+
break
11+
12+
blur = cv2.GaussianBlur(frame, (21, 21), 0)
13+
hsv = cv2.cvtColor(blur, cv2.COLOR_BGR2HSV)
14+
15+
lower = [18, 50, 50]
16+
upper = [35, 255, 255]
17+
lower = np.array(lower, dtype="uint8")
18+
upper = np.array(upper, dtype="uint8")
19+
mask = cv2.inRange(hsv, lower, upper)
20+
21+
22+
23+
output = cv2.bitwise_and(frame, hsv, mask=mask)
24+
no_red = cv2.countNonZero(mask)
25+
cv2.imshow("output", output)
26+
#print("output:", frame)
27+
if int(no_red) > 20000:
28+
print ('Fire detected')
29+
#print(int(no_red))
30+
#print("output:".format(mask))
31+
if cv2.waitKey(1) & 0xFF == ord('q'):
32+
break
33+
34+
cv2.destroyAllWindows()
35+
video.release()

0 commit comments

Comments
 (0)