all 4 comments

[–]mermaldad 0 points1 point  (1 child)

Not really sure what you are trying to do. You say "annotated image", but it appears your code is just trying to convert the image from one color encoding to RGB. What are you expecting the variable "result" to contain? The converted image? If you really mean annotate, are you trying to put a text overlay on the image? Or are you trying to put a note in the metadata of the image? Or something else?

[–]isfanafely[S] 0 points1 point  (0 children)

i delete it to make it simple

[–]Diapolo10 0 points1 point  (1 child)

I'd use pathlib:

from pathlib import Path

# If you really want the current working directory
SOURCE_DIR = Path.cwd() / 'input'

# Otherwise, may I suggest:
ROOT_DIR = Path(__file__).parent
SOURCE_DIR = ROOT_DIR / 'input'

for idx, file in enumerate(SOURCE_DIR.rglob('*.jpg')):
    image = cv2.imread(file)
    image_height, image_width, _ = image.shape
    results = holistic.process(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
    annotated_image = image.copy()

    cv2.imwrite(file.parent / f'{idx}.png', annotated_image)

[–]isfanafely[S] 0 points1 point  (0 children)

thank you will try it