|
|
@@ -39,10 +39,12 @@ import static org.opencv.imgproc.Imgproc.*;
|
|
|
|
|
|
@Service
|
|
|
public class VideoRecognitionServiceImpl implements VideoRecognitionService {
|
|
|
- public static boolean DEBUG = false;
|
|
|
- private ThreadPoolExecutor executor = new ThreadPoolExecutor(10, 10, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<>());
|
|
|
- private Map<String, Map<String, Object>> resultMap = new HashMap<>();
|
|
|
- private Map<String, Long> lastStat = new HashMap<>();
|
|
|
+ public static boolean DEBUG = false;
|
|
|
+ private static Map<String, Map<String, Object>> resultMap = new HashMap<>();
|
|
|
+ private static Map<String, Long> lastStat = new HashMap<>();
|
|
|
+ private static Map<String, Object> processing = new HashMap<>();
|
|
|
+
|
|
|
+ private ThreadPoolExecutor executor = new ThreadPoolExecutor(10, 10, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<>());
|
|
|
|
|
|
static {
|
|
|
CLibrary.INSTANCE.setlocale(CLibrary.LC_ALL, "C");
|
|
|
@@ -66,6 +68,9 @@ public class VideoRecognitionServiceImpl implements VideoRecognitionService {
|
|
|
|
|
|
@Override
|
|
|
public boolean start(String videoPath) {
|
|
|
+ if (processing.get(videoPath) != null) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
lastStat.put(videoPath, System.currentTimeMillis());
|
|
|
resultMap.remove(videoPath);
|
|
|
VideoCapture capture = new VideoCapture();
|
|
|
@@ -124,6 +129,7 @@ public class VideoRecognitionServiceImpl implements VideoRecognitionService {
|
|
|
frame.release();
|
|
|
v.release();
|
|
|
System.gc();
|
|
|
+ processing.remove(videoPath);
|
|
|
});
|
|
|
return true;
|
|
|
}
|