Ask Your Question
0

Trying to convert 'BGR to Gray'

asked 2019-04-24 11:50:31 -0500

updated 2019-04-24 13:40:09 -0500

supra56 gravatar image

This is the input code:

import cv2
img = cv2.imread('test.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

And the error :

error: OpenCV(3.4.2) c:\miniconda3\conda-bld\opencv-suite_1534379934306\work\modules\imgproc\src\color.hpp:253: error: (-215:Assertion failed) VScn::contains(scn) && VDcn::contains(dcn) && VDepth::contains(depth) in function 'cv::CvtHelper<struct cv::set&lt;3,4,-1="">,struct cv::Set<1,-1,-1>,struct cv::Set<0,2,5>,2>::CvtHelper'C:\fakepath\test.jpg

edit retag flag offensive close merge delete

Comments

your image was empty. it was never correctly loaded,and you cannot convert an empty image, ok ?

berak gravatar imageberak ( 2019-04-24 14:21:55 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-04-24 13:53:47 -0500

supra56 gravatar image

updated 2019-04-24 14:03:29 -0500

Here is code:

import cv2

img = cv2.imread('test.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.imshow('Gray Photo', gray)
cv2.imshow('Photo', img)
cv2.waitKey(0)
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-04-24 11:50:31 -0500

Seen: 201 times

Last updated: Apr 24