45 lines
2.1 KiB
Python
Executable File
45 lines
2.1 KiB
Python
Executable File
import os,torch,cv2
|
|
from System_I import Detection_S,Fine_grained
|
|
from vediotoima import vedio_img
|
|
def GYD_RedCameraDeal (root,DetectionCalss,Fine_grainedClass):
|
|
CameraLists = os.listdir(root)
|
|
for CameraIMEI in CameraLists:
|
|
if not os.path.exists(os.path.join(root+"_Result",CameraIMEI)):
|
|
os.mkdir(os.path.join(root+"_Result",CameraIMEI))
|
|
image_videolists = os.listdir(os.path.join(root,CameraIMEI))
|
|
for image_video in image_videolists:
|
|
if "JPG" in image_video:
|
|
pass
|
|
# print(image_video, " is starting")
|
|
# image = cv2.imread(os.path.join(root,CameraIMEI,image_video))
|
|
# DetectionCalss.inference_Red(image,os.path.join(root,CameraIMEI,image_video),Fine_grainedClass)
|
|
# print(image_video," is ok")
|
|
else:
|
|
video_path = os.path.join(root, CameraIMEI,image_video)
|
|
video_path_out = os.path.join(root + "_Result", CameraIMEI, "RAWImage",image_video.replace(".MP4",""))
|
|
vedio_img(video_path,video_path_out,25)
|
|
isExists = os.path.exists(os.path.join(root + "_Result", CameraIMEI, "VideoResult",image_video.replace(".MP4","")))
|
|
if not isExists:
|
|
os.makedirs(os.path.join(root + "_Result", CameraIMEI, "VideoResult",image_video.replace(".MP4","")))
|
|
img_lists = os.listdir(video_path_out)
|
|
img_lists.sort()
|
|
|
|
for img in img_lists:
|
|
|
|
image = cv2.imread(os.path.join(video_path_out, img))
|
|
DetectionCalss.inference_Red(image, os.path.join(root, CameraIMEI, "VideoResult",image_video.replace(".MP4",""),img),
|
|
Fine_grainedClass)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
os.environ['CUDA_VISIBLE_DEVICES'] = '4'
|
|
devices = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
|
|
root = "/data1/Hatcher/ftp"
|
|
Detection1 = Detection_S(devices, root)
|
|
Fine_grained1 = Fine_grained(devices, root)
|
|
GYD_RedCameraDeal(root,Detection1,Fine_grained1)
|