First time here? Check out the FAQ!

Ask Your Question
0

Error could not find a writer....

asked Nov 29 '16

Katie gravatar image

updated Nov 29 '16

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?

Preview: (hide)

1 answer

Sort by » oldest newest most voted
1

answered Nov 29 '16

berak gravatar image

updated Nov 29 '16

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 ;)

Preview: (hide)

Comments

Thank you!

Katie gravatar imageKatie (Nov 30 '16)edit

Question Tools

2 followers

Stats

Asked: Nov 29 '16

Seen: 16,392 times

Last updated: Nov 29 '16