Ask Your Question
0

Error could not find a writer....

asked 2016-11-29 09:54:09 -0600

Katie gravatar image

updated 2016-11-29 10:26:24 -0600

berak gravatar image
import cv2 

# 0 is refrencing first camera
camera = cv2.VideoCapture(0)

# range is repeating the indented code by whatever is in ()
for i in range(2):
    return_value, img = camera.read()
    cv2.imshow('opencv'+str(i)+'png',img)
    cv2.imwrite('opencv'+str(i)+'png',img)
cv2.waitKey()
del camera

It keeps telling me " error: (-2) could not find a writer for the specified extension in function cv:: imwrite_"

Any ideas why?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-11-29 10:29:17 -0600

berak gravatar image

updated 2016-11-29 10:50:54 -0600

oh, that's a simple one:

you want to write opencv13.png, but forgot to put a dot between filename and extension

 filename = 'opencv'+str(i)+'.png'
 cv2.imwrite(filename, img) #  .png !
 cv2.imshow(filename, img)  # don't replicate

will do the trick ;)

edit flag offensive delete link more

Comments

Thank you!

Katie gravatar imageKatie ( 2016-11-30 14:50:25 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2016-11-29 09:54:09 -0600

Seen: 16,256 times

Last updated: Nov 29 '16