This code is for detecting fire using tensorflow keras model and I do not know how to draw rectangle around the fire detected object:
model = tf.keras.models.load_model('my_model\\InceptionV3.h5')
video = cv2.VideoCapture(0)
while True:
_, frame = video.read()
im = Image.fromarray(frame, 'RGB')
im = im.resize((224, 224))
img_array = image.img_to_array(im)
img_array = np.expand_dims(img_array, axis=0) / 255
probabilities = model.predict(img_array)[0]
prediction = np.argmax(probabilities)
# if prediction is 0, which means there is fire in the frame.
if prediction == 0:
img = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
print(probabilities[prediction])
cv2.imshow("Capturing", frame)
cv2.imshow("Capturing", img)
if cv2.waitKey(1) & 0xff == ord('q'):
break
video.release()
cv2.destroyAllWindows()