python 简单线程和 - OPENCV-示例

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 简单线程和 - OPENCV-示例相关的知识,希望对你有一定的参考价值。

# import libraries
import cv2
import numpy
import threading
import os
import random

path_to_file        = "temp-files/imgs/"
file_name           = "attempt{file}.png"

def workFucnt1(path_to_file, file_name):

    for each in range(500):
        # creating a circle with openCV
        # set up numpy array
    
        img         = numpy.zeros( (512,512,3), numpy.uint8 )

        # format the file path
        fileName    = file_name.format(file=each)
        randSeed    = each

        path        = path_to_file + fileName

        xPos        = int( tdu.rand(randSeed) * 512 )
        yPos        = int( tdu.rand(randSeed + 1) * 512)

        # draw a circle with openCV
        circle      = cv2.circle(img, (xPos, yPos), 63, (0,0,255), -1)

        # save the resulting image
        cv2.imwrite(path, circle)

    return

# un-comment this line below to see the process block touch
# workFucnt1(path_to_file, file_name)

# un-comment the bottom two lines to see the process
# execute without blocking Touch
myThread            = threading.Thread(target=workFucnt1, args=(path_to_file, file_name,))
myThread.start()

以上是关于python 简单线程和 - OPENCV-示例的主要内容,如果未能解决你的问题,请参考以下文章

OpenCV-Python实战——OpenCV用于图像分割的阈值技术(含大量示例,建议收藏)

Python OpenCV 错误:当前线程不是对象的线程

多线程本地图片加载示例OpenCVPthread

Python爬虫—多线程的简单示例

Python OpenCV线程

OpenCV 和 Python 多线程 - 在 VideoCapture 对象中搜索