S
samaneh.yahyapour
hi
my program work by 4 thread but when i use more thread it terminates
i use opencv in my image_process.so
my code is :
#!/usr/bin/python
import sys
import os
import io
import time
import copy
import threading
import ctypes
class MyClass():
def __init__(self):
i = 0
while i<10:
thread1 = threading.Thread(target=self.item_thread)
thread1.start()
i = i+1
time.sleep(0.01)
def item_thread(self):
imageAnalyzer=ctypes.CDLL("../so/image_process.so")
imageAnalyzer.aref_img_score_init("/opt/amniran/etc/face.xml", "/opt/amniran/etc/porn.xml")
for filename in os.listdir("../script/images/"):
if filename[-4:] == ".jpg" or filename[-4:] == ".png" or filename[-4:] == ".gif" or filename[-5:] == ".jpeg" :
path = "../script/images/%s"%filename
fo = file(path, "r")
content = fo.read()
score = imageAnalyzer.score_image(content, len(content))
print "%d : %s " %(score, path)
print "ENDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
x = MyClass()
how can i solve this problem
my program work by 4 thread but when i use more thread it terminates
i use opencv in my image_process.so
my code is :
#!/usr/bin/python
import sys
import os
import io
import time
import copy
import threading
import ctypes
class MyClass():
def __init__(self):
i = 0
while i<10:
thread1 = threading.Thread(target=self.item_thread)
thread1.start()
i = i+1
time.sleep(0.01)
def item_thread(self):
imageAnalyzer=ctypes.CDLL("../so/image_process.so")
imageAnalyzer.aref_img_score_init("/opt/amniran/etc/face.xml", "/opt/amniran/etc/porn.xml")
for filename in os.listdir("../script/images/"):
if filename[-4:] == ".jpg" or filename[-4:] == ".png" or filename[-4:] == ".gif" or filename[-5:] == ".jpeg" :
path = "../script/images/%s"%filename
fo = file(path, "r")
content = fo.read()
score = imageAnalyzer.score_image(content, len(content))
print "%d : %s " %(score, path)
print "ENDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
x = MyClass()
how can i solve this problem