1
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
1
  • you cannot put a colour image into cv2.Laplacian(). convert it to grayscale Commented Nov 16, 2017 at 16:04

1 Answer 1

1

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..

Sign up to request clarification or add additional context in comments.

3 Comments

Sreeram, I still got the same error after converting to grayscale.
Can you capture image from the camera and display it.??
Yes, I did that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.