-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcameraTester.py
89 lines (68 loc) · 2.42 KB
/
cameraTester.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import cv2
################################################################################################
# INFORMATION
#
# File Name : cameraTester.py
# Developer : Rishi Balasubramanian
# Call Sign : RBGA
# First Stable Build : 15th JULY 2024
# Use Case : Custom Python Program to test various Camera Modes of OpenCV
#
# Type : Executbale
# Inputs : None
#
# Output : Video Display and Log Text
# Description : Custom Python Program to test various Camera Modes of OpenCV
#
# ------------------------------------------------------------------
# LAST MODIFICATION
# Developer : Rishi Balasubramanian
# Call Sign : RBGA
# Date of Modification : 25th JULY 2024
#
# Description : Added Information Block and Code Module
# Block for every Code Module in the file.
#------------------------------------------------------------------
#
################################################################################################
# # Open the default camera (0)
# cap = cv2.VideoCapture(0, cv2.CAP_ANY)
# if not cap.isOpened():
# print("Error: Could not open camera.")
# exit()
# while True:
# ret, frame = cap.read()
# if not ret:
# print("Error: Failed to grab frame.")
# break
# cv2.imshow('Camera', frame)
# # Exit on pressing 'q'
# if cv2.waitKey(1) & 0xFF == ord('q'):
# break
# # Release the camera and close windows
# cap.release()
# cv2.destroyAllWindows()
import cv2
def has_alpha_channel(video_path):
cap = cv2.VideoCapture(video_path)
if not cap.isOpened():
raise Exception(f"Error opening video file {video_path}")
has_alpha = False
while True:
ret, frame = cap.read()
if not ret:
break
# Print dtype and shape of the frame
print(f"Frame dtype: {frame.dtype}")
print(f"Frame shape: {frame.shape}")
if len(frame.shape) == 3 and frame.shape[2] == 4:
has_alpha = True
break
cap.release()
return has_alpha
if __name__ == '__main__':
video_path = 'UiElements/detectIdleState_1.avi'
if has_alpha_channel(video_path):
print("The video has an alpha channel.")
else:
print("The video does not have an alpha channel.")