Scene Detection issue

I’m trying to detect the scenes of two clips:

cap = cv2.VideoCapture(‘first.mp4’, 0)

scene_manager = SceneManager()

scene_manager.add_detector(ContentDetector(threshold=30.0))

cap2 = cv2.VideoCapture(‘second.mp4’, 0)

scene_manager2 = SceneManager()

scene_manager2.add_detector(ContentDetector(threshold=30.0))

if (cap.isOpened()== False):

print(“Error opening video stream or file”)

if (cap2.isOpened()== False):

print(“Error opening video stream or file”)

src_image = scene_manager.detect_scenes(cap)

src_image_example = cv2.cvtColor(src_image, cv2.COLOR_BGR2RGB)

tar_image = scene_manager2.detect_scenes(cap2)

tar_image_example = cv2.cvtColor(tar_image, cv2.COLOR_BGR2RGB)

However, I get the following error:

error: OpenCV(4.1.2) /io/opencv/modules/imgproc/src/color.simd_helpers.hpp:94: error: (-2:Unspecified error) in function ‘cv::impl::{anonymous}::CvtHelper<VScn, VDcn, VDepth, sizePolicy>::CvtHelper(cv::InputArray, cv::OutputArray, int) [with VScn = cv::impl::{anonymous}::Set<1>; VDcn = cv::impl::{anonymous}::Set<3, 4>; VDepth = cv::impl::{anonymous}::Set<0, 2, 5>; cv::impl::{anonymous}::SizePolicy sizePolicy = (cv::impl::::SizePolicy)2u; cv::InputArray = const cv::_InputArray&; cv::OutputArray = const cv::_OutputArray&]’
Unsupported depth of input image:
‘VDepth::contains(depth)’
where
‘depth’ is 6 (CV_64F)

Looking at the tutorial https://pyscenedetect.readthedocs.io/projects/Manual/en/latest/api/scene_manager.html#scenedetect.scene_manager.SceneManager.detect_scenes
I think my issue is that SceneManager.detect_scenes() just returns an int representing how many frames have been processed, but

cv2.cvtColor()

is expecting to be passed an image, or a numpy array.

Is there any way how I can overcome this issue?

Thanks in advance!

Hi,
scene_manager is not opencv. Forum is about opencv
a numpy array is an image.

you’re right.

what is the actual issue ? what are you trying to achieve ? why are you using that library (with which we, again, cannot help) ?

The issue is that I want to do some operations on extracted scenes (few frames) instead of doing process on all frames (for the performance). Is there any other way (library) then to perform the intended?

if you have frame numbers, you can get an image from the capture:

cap.set(cv2.CAP_PROP_POS_FRAMES, frame_no)
ret, img = cap.read();
1 Like

I have no problems with getting an image from the capture.
The problem is that I’m dealing with the shape processing of the image which requires an image or a numpy array to be passed after the scene detection.

that is the whole error.

you give OpenCV a numpy array of doubles when it does not want that.

make sure your data is FP32 (single precision float) or some other type. do that when the data is created, or use numpy’s yourarray.astype(np.float32) to convert

1 Like