Skip to content

cv2.resize blocks forever when called by multiple processes(with multiprocessing module) #69

@bombs-kim

Description

@bombs-kim

Expected behaviour

N/A

Actual behaviour

I encountered a strange behavior of cv2.resize. I prepared a snippet that reproduces the strange behavior. pool.map blocks forever in the code below because any of those processes doesn't finish its job. The reason why I see it strange is that the code works okay when pool.map is not followed by "Single processing" code.

Steps to reproduce

#example code

import cv2
import multiprocessing


def process_image(image_path):
    proc = multiprocessing.current_process().name
    print proc, "processing image.."
    img_input = cv2.imread(image_path, 0)
    scale = 1.2
    cv2.resize(img_input, (0, 0), fx=scale, fy=scale)
    print proc, "finished"


def main():
    image_path = '.../image.jpg'
    # Single processing. If you comment out the line bellow, main function works just okay
    process_image(image_path)

    # Multi processing
    num_processes = 5
    pool = multiprocessing.Pool(num_processes)
    pool.map(process_image, [image_path]*num_processes)

if __name__ == '__main__':
    main()
  • operating system / architecture (e.g. x86)
    Ubuntu 16.04 / x86_64

  • version
    python 2.7.14(Anconda)
    opencv-python==3.2.0.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions