I tried using imWrite instead of imshow as an attempt to save my files locally. However, each image being saved is overlapped by the next one. How can I save all of the photos altogether without them overlapping each other?
you need to save them with a different title. you can add a counter variable outside the loop and increase it by one on each loop: counter = 0 while True: counter += 1 cv2.imwrite(str(counter) + ".jpg", frame)
@@pysource-com is this correct? please correct me if im wrong #dataset and augmentation code counter = 0 while True: augmented_images = augmentation(images=images) for img in augmented_images: counter += 1 cv2.imwrite(str(counter) + ".jpg", frame) cv2.imwrite('Desktop/WartyAugmented/warty.png' ,img) #desired save location cv2.waitKey(0) also if this works, how do i limit the number of images that the augmentation will generate? thank you in advance
@@johnalfredcastaneda1596 use for loop instead of while loop.... augmentation_counter = 0 # the current loop of augmentation indicator for i in range(10): # desired amount of times you need to augment augmented_images = augmentation(images = images) counter = 0 # counter representing the index that distinguishes the 3 dogs for img in augmented_images: cv2.imshow("Image", img) cv2.imwrite(f'Data\augmented\{name_list[counter]}{augmentation_counter}.jpeg', img) cv2.waitKey(0) counter += 1 augmentation_counter += 1
cv2.imwrite(os.path.join(augment_path, f'{name_list[counter]}'+ '_' + f'{augmentation_counter}.jpeg'), img) #use this actually no the imwrite code in previous comment
Hey great video! Is there anyway to apply this to images as well as the .txt files containing the bounding box coordinates?(asking this in reference to object detection)
Yes, when this library is integrated with the deep learning framework (for example keras or pytorch), it also applies the augmentation to the annotations. see more info on the official github release: github.com/aleju/imgaug
Hello, I am working with multi classification task. I have 3 folders. One of classes has few images and I want to increase that folder. My question is how can i augment that folder 10 times and save it at the same folder? Thank you
]) train_path = 'Data/known' #training images path augment_path = 'Data/augmented' #augmented images path name_list = [] #collection of names myList = os.listdir(train_path) #list full name of all image file # test_path = 'Data\unknown' #test images path- live_path = 'Data/live' #live images path # make array of training images and corresponding person name for person in myList: name_list.append(os.path.splitext(person)[0]) augmentation_counter = 0 for i in range(1): augmented_images = augmentation(images = images) counter = 0 for img in augmented_images: cv2.imshow("Image", img) cv2.imwrite(os.path.join(augment_path, f'{name_list[counter]}'+ '_' + f'{augmentation_counter}.jpeg'), img) cv2.waitKey(0) counter += 1 augmentation_counter += 1
normally this is integrated with the deep learning framework, so you shouldn't save them, especially because they have annotations associated, which will also match the augmentation.
Dear Mr Sergio Canu Many thanks for your valuable information. Kindly give the code to save the augmented images into a folder. Thanks for your kind understanding and support.
That is great, I have a question but how to do augmentation to labeled images in yolo format
How can I save those generated images?
How can you move the bounding box along with the image rotation?
thank you, your explanation is easy to understand
how to save the image after augmentation? thanks
Hi, can you let me know how to save a video to my desktop using opencv
How can save generate image ?
I tried using imWrite instead of imshow as an attempt to save my files locally. However, each image being saved is overlapped by the next one. How can I save all of the photos altogether without them overlapping each other?
you need to save them with a different title.
you can add a counter variable outside the loop and increase it by one on each loop:
counter = 0
while True:
counter += 1
cv2.imwrite(str(counter) + ".jpg", frame)
@@pysource-com is this correct? please correct me if im wrong
#dataset and augmentation code
counter = 0
while True:
augmented_images = augmentation(images=images)
for img in augmented_images:
counter += 1
cv2.imwrite(str(counter) + ".jpg", frame)
cv2.imwrite('Desktop/WartyAugmented/warty.png' ,img) #desired save location
cv2.waitKey(0)
also if this works, how do i limit the number of images that the augmentation will generate? thank you in advance
@@johnalfredcastaneda1596 Hi, did you solve this problem?
@@johnalfredcastaneda1596 use for loop instead of while loop....
augmentation_counter = 0 # the current loop of augmentation indicator
for i in range(10): # desired amount of times you need to augment
augmented_images = augmentation(images = images)
counter = 0 # counter representing the index that distinguishes the 3 dogs
for img in augmented_images:
cv2.imshow("Image", img)
cv2.imwrite(f'Data\augmented\{name_list[counter]}{augmentation_counter}.jpeg', img)
cv2.waitKey(0)
counter += 1
augmentation_counter += 1
cv2.imwrite(os.path.join(augment_path, f'{name_list[counter]}'+ '_' + f'{augmentation_counter}.jpeg'), img) #use this actually no the imwrite code in previous comment
Hello, How can i place all augmented images into new folder?
Thank you
Thanks much. Is there a way to detect side angle without eyes
Awesome video but... i was expecting to show how to save the augmented images locally to the PC!
Fantastic tutorial, thanks a lot man !
Hey great video! Is there anyway to apply this to images as well as the .txt files containing the bounding box coordinates?(asking this in reference to object detection)
Yes, when this library is integrated with the deep learning framework (for example keras or pytorch), it also applies the augmentation to the annotations.
see more info on the official github release: github.com/aleju/imgaug
@@pysource-com Oh great thanks for your reply
Hello,
I am working with multi classification task. I have 3 folders. One of classes has few images and I want to increase that folder. My question is how can i augment that folder 10 times and save it at the same folder?
Thank you
use open cv to write images and save it to any folder u want
Thanks for awesome tutorials, can you show us how to stream a video from opencv to rtsp?
yo can anyone tell me how to actually store those augmented imgs as .jpeg
import imgaug.augmenters as iaa
import cv2
import os
import glob
images = []
images_path = glob.glob('Data\known\*.jpeg')
for img_path in images_path:
img = cv2.imread(img_path)
images.append(img)
augmentation = iaa.Sequential([
iaa.Rotate((-30,30)),
iaa.Fliplr(0.5),
iaa.Flipud(0.5),
iaa.Affine(translate_percent={"x": (-0.2,-0.2), "y": (-0.2,-0.2)},
rotate=(-30,30),
scale=(0.5, 1.5)
),
iaa.Multiply((0.8, 1.2)),
iaa.LinearContrast((0.6, 1.4)),
iaa.Sometimes(0.5,
iaa.GaussianBlur((0.0, 3.0))
)
])
train_path = 'Data/known' #training images path
augment_path = 'Data/augmented' #augmented images path
name_list = [] #collection of names
myList = os.listdir(train_path) #list full name of all image file
# test_path = 'Data\unknown' #test images path-
live_path = 'Data/live' #live images path
# make array of training images and corresponding person name
for person in myList:
name_list.append(os.path.splitext(person)[0])
augmentation_counter = 0
for i in range(1):
augmented_images = augmentation(images = images)
counter = 0
for img in augmented_images:
cv2.imshow("Image", img)
cv2.imwrite(os.path.join(augment_path, f'{name_list[counter]}'+ '_' + f'{augmentation_counter}.jpeg'), img)
cv2.waitKey(0)
counter += 1
augmentation_counter += 1
nice and to save them on a local drive?
normally this is integrated with the deep learning framework, so you shouldn't save them, especially because they have annotations associated, which will also match the augmentation.
Sir this was very helpful thanks. Have liked and subscribed
Dear Mr Sergio Canu
Many thanks for your valuable information.
Kindly give the code to save the augmented images into a folder.
Thanks for your kind understanding and support.
I'm working on a project like you mentioned, If you are still interested after 2 years, I can share with you after I finish the saving images part🙂
great tutorial! but can you finally answer those questions in comments? ;__; please that would be really helpful as well
Make please a video about Face_recognition
thank you very much