OpenCV(4.5.5) :-1: 错误: (-5:Bad argument) 在函数“cvtColor”中
你们能帮我吗?我正在尝试使用我自己的数据(路径=数据)通过在我的视频上应用媒体管道来创建数据集。处理后的 vid (.ny) 将位于我之前声明的输出文件夹 (path = O_Video) 中。 seq 数量为 30,因为我有 30 个视频,start_folder = 0 且 start_video = 0。
videos = cv2.VideoCapture(IMPORT_DATA)
videos_input = cv2.cvtColor(videos, cv2.COLOR_BGR2RGB)
# Set mediapipe model
with mp_holistic.Holistic(min_detection_confidence=0.5, min_tracking_confidence=0.5) as holistic:
# NEW LOOP
# Loop through actions
for action in actions:
# Loop through sequences aka videos
for sequence in range(start_folder, start_video+no_sequences):
# get results
results = mp_face.process(videos_input)
for detection in results.detections: # iterate over each detection and draw on image
mp_drawing.draw_detection(videos, detection)
# NEW Export keypoints
keypoints = extract_keypoints(results)
npy_path = os.path.join(DATA_PATH, action, str(sequence))
np.save(npy_path, keypoints)
# Break gracefully
if cv2.waitKey(10) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
我收到的错误如下:
Error Traceback (most recent call last)
Input In [15], in <module>
1 videos = cv2.VideoCapture(IMPORT_DATA)
----> 2 videos_input = cv2.cvtColor(videos, cv2.COLOR_BGR2RGB)
4 # Set mediapipe model
5 with mp_holistic.Holistic(min_detection_confidence=0.5, min_tracking_confidence=0.5) as holistic:
6
7 # NEW LOOP
8 # Loop through actions
error: OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'cvtColor'
> Overload resolution failed:
> - src is not a numpy array, neither a scalar
> - Expected Ptr<cv::UMat> for argument 'src'
Can you guys help me? I'm trying to use my own data (path = data) to create a dataset by applying the mediapipe on my videos. The processed vid (.ny) will be in output folder (path = O_Video) which I have declared previously. No of seq is 30 as I have 30 videos with the start_folder = 0 and start_video = 0.
videos = cv2.VideoCapture(IMPORT_DATA)
videos_input = cv2.cvtColor(videos, cv2.COLOR_BGR2RGB)
# Set mediapipe model
with mp_holistic.Holistic(min_detection_confidence=0.5, min_tracking_confidence=0.5) as holistic:
# NEW LOOP
# Loop through actions
for action in actions:
# Loop through sequences aka videos
for sequence in range(start_folder, start_video+no_sequences):
# get results
results = mp_face.process(videos_input)
for detection in results.detections: # iterate over each detection and draw on image
mp_drawing.draw_detection(videos, detection)
# NEW Export keypoints
keypoints = extract_keypoints(results)
npy_path = os.path.join(DATA_PATH, action, str(sequence))
np.save(npy_path, keypoints)
# Break gracefully
if cv2.waitKey(10) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
Error that I'm getting is as below:
Error Traceback (most recent call last)
Input In [15], in <module>
1 videos = cv2.VideoCapture(IMPORT_DATA)
----> 2 videos_input = cv2.cvtColor(videos, cv2.COLOR_BGR2RGB)
4 # Set mediapipe model
5 with mp_holistic.Holistic(min_detection_confidence=0.5, min_tracking_confidence=0.5) as holistic:
6
7 # NEW LOOP
8 # Loop through actions
error: OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'cvtColor'
> Overload resolution failed:
> - src is not a numpy array, neither a scalar
> - Expected Ptr<cv::UMat> for argument 'src'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法将
VideoCapture
对象传递给cvtColor
。您必须单独传递每个帧(numpy 数组)。
You can't pass a
VideoCapture
object tocvtColor
.You have to pass each frame (numpy array) individually.
您需要捕获帧数据,如下所示。
you need to capture the frame data as shown below.