0

I am looking to save a set of processed images into a folder within my directory. There have been similar questions (e.g., Save images in loop with different names), however they either use user defined functions or rely on the images being part of a video that they decompose frame-by-frame and then save.

Using another question, I was looking to accomplish something similar (OpenCV - Saving images to a particular folder of choice), but within a loop structure

import cv2
import os

path = 'D:\Results'

for i in range(len(images))
     cv2.imwrite(os.path.join(path, 'waka.tif'), )
     cv2.waitKey(0)

But am unsure of what to put in place of the waka title the previous questioner gave the image.

2
  • Why don't you put a timestamp instead of waka if that is the question Commented Jul 31, 2019 at 13:58
  • Oh, I see what you are asking what to pass to opencv to write at the path location right? What does images contain? Commented Jul 31, 2019 at 14:01

2 Answers 2

2

you can put 'waka_{}.tif'.format(i) this will save one image every time it goes through the loop and you will then have waka_1.tif, waka_2.tif, etc.

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

Comments

1

you can try this:

import cv2
import os

path = 'D:\Results'

for i in range(len(images))
     cv2.imwrite(os.path.join(path, 'waka_'+str(i)+'.tif'), )
     cv2.waitKey(0)

Comments

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.