diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 94a25f7..03de193 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -2,5 +2,6 @@
+
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e69de29
diff --git a/core/models.py b/core/models.py
index 41ccc28..b131837 100755
--- a/core/models.py
+++ b/core/models.py
@@ -23,9 +23,15 @@ class VideoFile(models.Model):
video_width = models.IntegerField(default=0, blank=True)
video_height = models.IntegerField(default=0, blank=True)
status = models.IntegerField(default=VideoFileStatus.NEW.value)
+ output_file = models.FileField(upload_to="", max_length=1024, blank=True)
+ csv_file = models.FileField(upload_to="", max_length=1024, blank=True)
@property
def url(self):
return self.file.url
+
+class WTV2D_data(models.Model):
+ processing = models.BooleanField(default=False, blank=False)
+
diff --git a/core/templates/core/home.html b/core/templates/core/home.html
index ff7693d..937d6a9 100644
--- a/core/templates/core/home.html
+++ b/core/templates/core/home.html
@@ -12,6 +12,10 @@
+ {% if processing %}
+
Some video is still being processed
+
Video list
+ {% else %}
Submit your video
+
Video list
+ {% endif %}
diff --git a/core/templates/core/video_list.html b/core/templates/core/video_list.html
new file mode 100644
index 0000000..d8f15b0
--- /dev/null
+++ b/core/templates/core/video_list.html
@@ -0,0 +1,53 @@
+{% load static %}
+
+
+
+
+
+
+
+ Web-TV2D - Video list
+
+
+
+
Upload video
+
Refresh
+
+
+
+
+ # |
+ Video original file |
+ Video status |
+ Video processed file |
+ Video CSV file |
+
+
+
+ {% for video in videos %}
+
+ {{ video.pk }} |
+ {{ video.file }} |
+ {% if video.status == enum_video_file_status.NEW.value %}
+ NEW |
+ {% elif video.status == enum_video_file_status.PROCESSING.value %}
+ PROCESSING |
+ {% elif video.status == enum_video_file_status.READY.value %}
+ READY |
+ {% endif %}
+ {% if video.output_file and video.csv_file %}
+ {{ video.output_file }} |
+ {{ video.csv_file }} |
+ {% else %}
+ |
+ |
+ {% endif %}
+
+ {% endfor %}
+
+
+
+
+
+
diff --git a/core/urls.py b/core/urls.py
index 71a3ca8..54120e9 100644
--- a/core/urls.py
+++ b/core/urls.py
@@ -2,8 +2,7 @@ from django.contrib import admin
from django.urls import path
from . import views
-app_name = "menu"
-
urlpatterns = [
- path('' , views.home, name="home"),
+ path('/', views.home, name="home"),
+ path('videolist/', views.video_list_view, name="videolist"),
]
diff --git a/core/views.py b/core/views.py
index 82f2ada..52ea05f 100755
--- a/core/views.py
+++ b/core/views.py
@@ -3,27 +3,70 @@ from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.contrib import messages
from core.forms import VideoUploadForm
-from core.models import VideoFile
+from core.models import VideoFile, WTV2D_data
+from TV2D import TV2D
# Create your views here.
def home(request):
+ wtv2d_data = WTV2D_data.objects.first()
+ # For control processing videos some workers should be used like Celery
+ # if wtv2d_data.processing:
+ # context = {'processing': True}
+ # return render(request, 'core/home.html', context)
form = VideoUploadForm()
if request.method == "POST":
form = VideoUploadForm(request.POST, request.FILES)
if form.is_valid():
+ wtv2d_data.processing = True
+ wtv2d_data.save()
video_file = VideoFile(file=request.FILES['file'])
+ video_file.status = VideoFile.VideoFileStatus.NEW.value
video_file.save()
video = cv2.VideoCapture(video_file.file.path)
video_file.fps = video.get(cv2.CAP_PROP_FPS)
video_file.video_width = int(video.get(cv2.CAP_PROP_FRAME_WIDTH))
video_file.video_height = int(video.get(cv2.CAP_PROP_FRAME_HEIGHT))
+ video_file.status = VideoFile.VideoFileStatus.PROCESSING.value
video_file.save()
+ # object_detection_model_path = "COCO-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_3x.yaml"
+ object_detection_model_path = "COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml"
+ # Same as model by for now for config. If you use model from local sotrage you can still use config
+ ## from Detectron2 Model Zoo and Baselines.
+ # object_detection_config_path = "COCO-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_3x.yaml"
+ object_detection_config_path = "COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml"
+ homography_keypoint_path = "TV2D/models/FPN_efficientnetb3_0.0001_4.h5"
+ homography_deephomo_path = "TV2D/models/HomographyModel_0.0001_4.h5"
+ deep_sort_model = "TV2D/models/market_bot_R50.pth"
+ deep_sort_model_config = "TV2D/deep_sort_pytorch/thirdparty/fast-reid/configs/Market1501/bagtricks_R50.yml"
+
+ tv2d = TV2D.TV2D(object_detection_model_path, object_detection_config_path=object_detection_config_path,
+ homography_on=True, team_detection_on=True,
+ tracker_on=True, no_gui=True,
+ homography_pretreined=False, homography_deephomo_path=homography_deephomo_path,
+ homography_keypoint_path=homography_keypoint_path,
+ deep_sort_model_path=deep_sort_model, deep_sort_model_config=deep_sort_model_config)
+ output_video_name = ".".join(video_file.file.name.split(".")[:-1]) + "_" + str(video_file.pk) + ".mkv"
+ export_data_file_path = ".".join(video_file.file.name.split(".")[:-1]) + "_" + str(video_file.pk) + ".csv"
+ video_file.output_file = output_video_name
+ video_file.csv_file = export_data_file_path
+ video_file.save()
+ tv2d(TV2D.TV2D.RunOn.VIDEO, video_file.file.path, export_output_path=f"media/{output_video_name}",
+ export_data_file_path=f"media/{export_data_file_path}")
+ video_file.status = VideoFile.VideoFileStatus.READY.value
+ video_file.save()
else:
messages.error(request, "Something went wrong")
+ wtv2d_data.processing = False
+ wtv2d_data.save()
context = {'form': form}
return render(request, 'core/home.html', context)
+
+def video_list_view(request):
+ videos = VideoFile.objects.all().order_by("-pk")
+ context = {'videos': videos, 'enum_video_file_status': VideoFile.VideoFileStatus}
+ return render(request, 'core/video_list.html', context)