相关疑难解决方法(0)

Python多进程无法pickle opencv videocapture对象

我正在尝试创建一个独立的进程来处理从相机获取的图像。但多处理似乎很难从 opencv 中提取视频捕获模块。任何人都可以建议解决方法吗?我正在使用 python 3.7.1

from multiprocessing import Process
import multiprocessing as mp
import time
import logging
import logging.handlers
import sys

import logging
from enum import Enum
import cv2


class Logger():
    @property
    def logger(self):
        component = "{}.{}".format(type(self).__module__, type(self).__name__)
        #default log handler to dump output to console

        return logging.getLogger(component)



class MyProcess(Logger):

    def __init__(self, ):
        self.process = Process(target = self.run, args=())
        self.exit = mp.Event()
        self.logger.info("initialize class")
        self.capture = cv2.VideoCapture(0)

    def run(self):
        while not self.exit.is_set():

            pass
        print("You exited!")

    def shutdown(self):
        print("Shutdown initiated")
        self.exit.set() …
Run Code Online (Sandbox Code Playgroud)

python opencv pickle multiprocessing

8
推荐指数
1
解决办法
8567
查看次数

标签 统计

multiprocessing ×1

opencv ×1

pickle ×1

python ×1