1 | initial version |
WOOwww. That cool! I Solved your problem. The error you getting at:
c = max(contours, key = cv2.contourArea)
To fix problem: Put inside if/else
condition block:
if area>20000:
cv2.drawContours(fg, contours, -1, (0, 255, 0), 3)
c = max(contours, key = cv2.contourArea)
x,y,w,h = cv2.boundingRect(c)
# draw the book contour (in green)
cv2.rectangle(fg,(x,y),(x+w,y+h),(0,255,0),2)
cv2.imshow('bg', bg)
cv2.imshow('fg', fg)
cv2.imshow('panel', panel)
to:
if area>20000:
cv2.drawContours(fg, contours, -1, (0, 255, 0), 3)
c = max(contours, key = cv2.contourArea)
x,y,w,h = cv2.boundingRect(c)
# draw the book contour (in green)
cv2.rectangle(fg,(x,y),(x+w,y+h),(0,255,0),2)
cv2.imshow('bg', bg) cv2.imshow('fg', fg) cv2.imshow('panel', panel)
2 | No.2 Revision |
WOOwww. That cool! I Solved your problem. The error you getting at:
c = max(contours, key = cv2.contourArea)
To fix problem: Put inside if/else
condition block:
if area>20000:
cv2.drawContours(fg, contours, -1, (0, 255, 0), 3)
c = max(contours, key = cv2.contourArea)
x,y,w,h = cv2.boundingRect(c)
# draw the book contour (in green)
cv2.rectangle(fg,(x,y),(x+w,y+h),(0,255,0),2)
cv2.imshow('bg', bg)
cv2.imshow('fg', fg)
cv2.imshow('panel', panel)
to:
if area>20000:
cv2.drawContours(fg, contours, -1, (0, 255, 0), 3)
c = max(contours, key = cv2.contourArea)
x,y,w,h = cv2.boundingRect(c)
# draw the book contour (in green)
cv2.rectangle(fg,(x,y),(x+w,y+h),(0,255,0),2)
3 | No.3 Revision |
WOOwww. That cool! I Solved your problem. The error you getting at:
c = max(contours, key = cv2.contourArea)
To fix problem: Put inside if/else
condition block:
if area>20000:
cv2.drawContours(fg, contours, -1, (0, 255, 0), 3)
c = max(contours, key = cv2.contourArea)
x,y,w,h = cv2.boundingRect(c)
# draw the book contour (in green)
cv2.rectangle(fg,(x,y),(x+w,y+h),(0,255,0),2)
cv2.imshow('bg', bg)
cv2.imshow('fg', fg)
cv2.imshow('panel', panel)
to:
if area>20000:
cv2.drawContours(fg, contours, -1, (0, 255, 0), 3)
c = max(contours, key = cv2.contourArea)
x,y,w,h = cv2.boundingRect(c)
# draw the book contour (in green)
cv2.rectangle(fg,(x,y),(x+w,y+h),(0,255,0),2)
cv2.imshow('bg', bg)
cv2.imshow('fg', fg)
cv2.imshow('panel', panel)
Also change this:
capture = cv2.VideoCapture(1)
to:
capture = cv2.VideoCapture(0)