首页 > 解决方案 > 有没有办法中断训练过程?

问题描述

我是OpenCV的新手,我想使用python模块 ( opencv-python) 训练我的模型。

这是我的代码:

def startTraining():
    trainingThread = Thread(target=trainModel, args=())

def trainModel():
    # some code to get the faces and the ids
    recognizer.train(faces, np.array(ids))

def stopTraining()
    # some code to kill the training process

而且效果很好。

所以这是我的问题:有没有办法中断这个过程(杀死它,停止它......)?

之后我不需要能够重新启动该过程......我不知道如何使用threading来做到这一点。我想创建一个函数来终止进程。(例子)

任何帮助都是有用的,谢谢。

标签: pythonmultithreadingopencvtraining-dataopencv-python

解决方案


推荐阅读