Nagaraj
Nagaraj

Reputation: 668

edge detection using python

import cv2
import numpy as np

cap = cv2.VideoCapture()

while True:
    _, frame = cap.read()

    laplacia = cv2.Laplacian(frame, cv2.CV_64F)

    cv2.imshow('original', frame)
    cv2.imshow('laplacian', laplacia)

    k = cv2.waitKey(5) & 0xFF
    if k==27:
        break

cv2.destroyAllWindows()
cap.release()

I am getting this error

#laplacia = cv2.Laplacian(frame, cv2.CV_64F)
cv2.error: C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\core\src\matrix.cpp:981: error: (-215) dims <= 2 && step[0] > 0 in function cv::Mat::locateROI

Upvotes: 1

Views: 476

Answers (1)

Sreeram TP
Sreeram TP

Reputation: 11927

cv2.Laplacian() won't work with Color images.

You can go through OpenCV Documentation for knowing more..Image Gradients

You must convert the frame you have captured to gray scale and then apply Laplacian

gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

You can convert to gray scale as shown above..

Upvotes: 1

Related Questions