Unable to read image and vedio data in Databricks using OpenCV.

KVK
New Contributor II

I have tried reading image and video data in Azure databricks using OpenCv. When I have checked the type of image, it’s shown as “NonType” and when I tried with vedio file, the file itself was not being opened. (Note: these files are stored on azure blob storage and accesssed in databricks after mounting.)

OpenCV version: 4.5.5

Here is the code:

import numpy as np

import cv2

import ffmpeg

# Capture video from file

cap = cv2.VideoCapture('/dbfs:/databricks-datasets/cctvVideos/mp4/test/Browse1.mp4', cv2.FFMPEG)

while True:

success, img = cap.read()

print(success)

if success:

cv2.imshow("video", img)

cv2.waitKey(1)

if 0xFF == ord('q') :

break

else:

break

Does it have have any dependencies on other libraries?

sachinkumar
New Contributor II

Kindly let me know if you find the answer.!!