I am trying to save frames and their path into the Database and file storage, but somehow frames are not getting saved in the path I have provided, printing path seems to be fine , but I am only getting the directory which I am creating not the pictures inside of it , need help in this , thanks in advance
def get_frames(cap=0):
frames = cv2.VideoCapture(cap)
now_utc = dt.now(timezone('UTC'))
now_local = now_utc.astimezone(get_localzone())
data = {}
success,image = frames.read()
scaling_factor = 0.5
count = 0
while True:
if not success:
break
# save frame as JPEG file
success,image = frames.read()
image = cv2.flip(image,1)
#adding guassian blur
image = cv2.resize(image, None, fx=scaling_factor, fy=scaling_factor, interpolation=cv2.INTER_AREA)
# lower = [18, 50, 50]
# upper = [35, 255, 255]
# lower = np.array(lower, dtype="uint8")
# upper = np.array(upper, dtype="uint8")
# mask = cv2.inRange(hsv, lower, upper)
# output = cv2.bitwise_and(image, hsv, mask=mask)
# no_red = cv2.countNonZero(mask)
# if int(no_red) > 15000:
# Fire_Reported = Fire_Reported + 1
count += 1
cv2.imshow("frame", image)
ret,buffer = cv2.imencode('.jpeg',image)
dtString = dt.now().strftime('%d-%m-%Y')
BASE_DIR = Path(__file__).resolve().parent.parent
path = os.path.join(BASE_DIR,f'camera_frames_{dtString}')
if not os.path.exists(path):
os.makedirs(path)
imgName = os.path.join(path ,dt.now().strftime('%m/%d/%Y %I:%M:%S')+'.jpeg')
saved_frame = cv2.imwrite(imgName, image)
if count <= 20:
camera_ins = get_or_create(db.session,Cameras,alias_name='test_cam',camera_no=1)
frame_ins = CameraFrames(date_time=now_local.strftime(format),camera_image=imgName)
camera_ins.frames.append(frame_ins)
db.session.add(camera_ins)
db.session.add(frame_ins)
db.session.commit()
frame = buffer.tobytes()
yield(b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
if cv2.waitKey(10) == 27:
break
C:\Users\atifs\Documents\video_detect\camera_frames_17-10-2021\10/17/2021 03:43:21.jpegpaths are like this @Micka