diff --git a/base/__init__.py b/base/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/base/__pycache__/__init__.cpython-310.pyc b/base/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..9af6ffc Binary files /dev/null and b/base/__pycache__/__init__.cpython-310.pyc differ diff --git a/base/__pycache__/admin.cpython-310.pyc b/base/__pycache__/admin.cpython-310.pyc new file mode 100644 index 0000000..76d4107 Binary files /dev/null and b/base/__pycache__/admin.cpython-310.pyc differ diff --git a/base/__pycache__/apps.cpython-310.pyc b/base/__pycache__/apps.cpython-310.pyc new file mode 100644 index 0000000..bc1c43b Binary files /dev/null and b/base/__pycache__/apps.cpython-310.pyc differ diff --git a/base/__pycache__/models.cpython-310.pyc b/base/__pycache__/models.cpython-310.pyc new file mode 100644 index 0000000..1d85ef0 Binary files /dev/null and b/base/__pycache__/models.cpython-310.pyc differ diff --git a/base/__pycache__/urls.cpython-310.pyc b/base/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000..0a66476 Binary files /dev/null and b/base/__pycache__/urls.cpython-310.pyc differ diff --git a/base/__pycache__/views.cpython-310.pyc b/base/__pycache__/views.cpython-310.pyc new file mode 100644 index 0000000..e7a39d1 Binary files /dev/null and b/base/__pycache__/views.cpython-310.pyc differ diff --git a/base/admin.py b/base/admin.py new file mode 100644 index 0000000..352c120 --- /dev/null +++ b/base/admin.py @@ -0,0 +1,7 @@ +from django.contrib import admin + +from .models import * + + +admin.site.register(VideoPrs) + diff --git a/base/apps.py b/base/apps.py new file mode 100644 index 0000000..05011e8 --- /dev/null +++ b/base/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class BaseConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'base' diff --git a/base/migrations/0001_initial.py b/base/migrations/0001_initial.py new file mode 100644 index 0000000..d04d240 --- /dev/null +++ b/base/migrations/0001_initial.py @@ -0,0 +1,23 @@ +# Generated by Django 5.0.6 on 2024-06-12 19:42 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='VideoPrs', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('file_base', models.FileField(upload_to='video/')), + ('file_pres', models.FileField(upload_to='results/')), + ('file_cvs', models.FileField(upload_to='csv')), + ], + ), + ] diff --git a/base/migrations/__init__.py b/base/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/base/migrations/__pycache__/0001_initial.cpython-310.pyc b/base/migrations/__pycache__/0001_initial.cpython-310.pyc new file mode 100644 index 0000000..7aa5157 Binary files /dev/null and b/base/migrations/__pycache__/0001_initial.cpython-310.pyc differ diff --git a/base/migrations/__pycache__/__init__.cpython-310.pyc b/base/migrations/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..dcf3a2a Binary files /dev/null and b/base/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/base/models.py b/base/models.py new file mode 100644 index 0000000..9d35de2 --- /dev/null +++ b/base/models.py @@ -0,0 +1,15 @@ +from django.db import models + + + +class VideoPrs(models.Model) : + file_base = models.FileField(upload_to="video/") + file_pres = models.FileField(upload_to="results/") + file_cvs = models.FileField(upload_to="csvs") + + def delete(self ,*args, **kwargs) : + self.file_base.delete(save=False) + self.file_pres.delete(save=False) + self.file_cvs.delete(save=False) + super().delete(*args, **kwargs) + diff --git a/base/templates/404.html b/base/templates/404.html new file mode 100644 index 0000000..872251b --- /dev/null +++ b/base/templates/404.html @@ -0,0 +1,17 @@ + + + + + + 404 - Page Not Found + + + +
+

404

+

Oops! Page Not Found Or No Data found

+

We can't seem to find the page you're looking for.

+ Go Home +
+ + diff --git a/base/templates/contact.html b/base/templates/contact.html new file mode 100644 index 0000000..7bcb8d7 --- /dev/null +++ b/base/templates/contact.html @@ -0,0 +1,87 @@ +{% load static %} + + + + + + Contact Page + + + + + + + + +
+
+ +
+ +

Contact Us

+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+ +
+ Contact Us Photo +
+
+
+ + + + + + + + diff --git a/base/templates/index1.html b/base/templates/index1.html new file mode 100644 index 0000000..d503782 --- /dev/null +++ b/base/templates/index1.html @@ -0,0 +1,241 @@ +{% load static %} + + + + + + ANPR + + + + + + + + +
+ +
+ {% csrf_token %} +
+ + +
+ + + + +
+ +
+
+
+ +
+ +
+ {% if last_data %} +

Last Data exists and has {{ last_data|length }} items

+ {% else %} +

Last Data is empty

+ {% endif %} + + + + + + + + + + + {% for car in last_data %} + + + + + + {% endfor %} + +
Car idCar SpeedLicense Plate
{{ car.car_id }}{{ car.car_speed }}{{ car.license_plate }}
+
+ + +
+ +
+
+ + + + + + + + + diff --git a/base/templates/index2.html b/base/templates/index2.html new file mode 100644 index 0000000..5a3830e --- /dev/null +++ b/base/templates/index2.html @@ -0,0 +1,242 @@ +{% load static %} + + + + + + ANPR + + + + + + + + +
+ +
+ {% csrf_token %} +
+ + +
+ + + + + +
+ +
+
+
+ +
+ +
+ {% if last_data %} +

Last Data exists and has {{ last_data|length }} items

+ {% else %} +

Last Data is empty

+ {% endif %} + + + + + + + + + + + {% for car in last_data %} + + + + + + {% endfor %} + +
Car idCar SpeedLicense Plate
{{ car.car_id }}{{ car.car_speed }}{{ car.license_plate }}
+
+ + +
+ +
+
+ + + + + + + + + diff --git a/base/templates/login.html b/base/templates/login.html new file mode 100644 index 0000000..d14e9a2 --- /dev/null +++ b/base/templates/login.html @@ -0,0 +1,79 @@ + + + + + + Login Page + + + + + + + + +
+ +
+ +
+ Logo +
+

Login

+
+
+ + +
+
+ + +
+
+ + Forgot Password? +
+
+
+
+ + + + + diff --git a/base/templates/show.html b/base/templates/show.html new file mode 100644 index 0000000..76c69f2 --- /dev/null +++ b/base/templates/show.html @@ -0,0 +1,21 @@ + + + + All Videos + + + + +
+ {% for x in video %} +

{{ x.name }}

+ + + + {% endfor %} +
+ + \ No newline at end of file diff --git a/base/tests.py b/base/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/base/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/base/urls.py b/base/urls.py new file mode 100644 index 0000000..b32d52e --- /dev/null +++ b/base/urls.py @@ -0,0 +1,17 @@ +from django.conf import settings +from django.urls import path +from django.conf.urls.static import static +from . import views + +urlpatterns = [ + path('',views.main , name="home"), + path('Show/' ,views.show), + path('Test/' , views.test , name="test"), + path('NoDataFound/', views.data_found) , + path('Contact/', views.contact , name="contact") + +] +if settings.DEBUG: + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + + diff --git a/base/views.py b/base/views.py new file mode 100644 index 0000000..98717c1 --- /dev/null +++ b/base/views.py @@ -0,0 +1,86 @@ +from django.http import JsonResponse +from django.shortcuts import render , redirect +import tempfile +from django.core.files.storage import FileSystemStorage +import json +import csv +from .models import * +import os +from ANPR.anpr import upload_anpr + + + +def main(request) : + data_tabel = {} + if request.method == 'POST': + video = request.FILES.get('video') + if video : + + fs = FileSystemStorage() + temp_file_path = fs.save(video.name, video) + temp_file_absolute_path = fs.path(temp_file_path) + + + json_data = upload_anpr(temp_file_absolute_path) + + + additional_data = json_data + + fs.delete(temp_file_path) + last_data = [] + + + cleaned_data = {k: v for k, v in additional_data.items() if v != {}} + + + for car_id, data in cleaned_data.items(): + for _, entry in data.items(): + if "car_speed" in entry and "license_plate" in entry and "text" in entry["license_plate"]: + _j = { + "car_id": car_id, + "car_speed": entry["car_speed"], + "license_plate": entry["license_plate"]["text"] + } + last_data.append(_j) + return render(request , "index1.html" , {'last_data': last_data}) + + else: + return redirect("/NoDataFound") + + return render(request , "index1.html") + + +def test(request) : + additional_data = {0: {}, 1: {}, 2: {}, 3: {}, 4: {}, 5: {}, 6: {}, 7: {}, 8: {}, 9: {}, 10: {}, 11: {}, 12: {}, 13: {}, 14: {}, 15: {}, 16: {}, 17: {}, 18: {}, 19: {}, 20: {}, 21: {}, 22: {}, 23: {}, 24: {}, 25: {}, 26: {}, 27: {}, 28: {}, 29: {}, 30: {}, 31: {}, 32: {}, 33: {}, 34: {}, 35: {}, 36: {}, 37: {}, 38: {}, 39: {}, 40: {}, 41: {}, 42: {}, 43: {}, 44: {}, 45: {}, 46: {}, 47: {}, 48: {}, 49: {}, 50: {}, 51: {}, 52: {}, 53: {}, 54: {}, 55: {}, 56: {}, 57: {}, 58: {}, 59: {}, 60: {}, 61: {}, 62: {}, 63: {}, 64: {}, 65: {}, 66: {}, 67: {}, 68: {}, 69: {}, 70: {}, 71: {}, 72: {}, 73: {}, 74: {}, 75: {}, 76: {}, 77: {}, 78: {}, 79: {}, 80: {}, 81: {}, 82: {}, 83: {}, 84: {}, 85: {}, 86: {}, 87: {}, 88: {}, 89: {}, 90: {}, 91: {}, 92: {}, 93: {}, 94: {}, 95: {}, 96: {}, 97: {}, 98: {}, 99: {}, 100: {}, 101: {}, 102: {}, 103: {}, 104: {}, 105: {}, 106: {}, 107: {}, 108: {}, 109: {}, 110: {}, 111: {}, 112: {}, 113: {}, 114: {}, 115: {8.0: + {'car': {'bbox': [574.0766191663662, 533.2293557055823, 810.3656132635728, 740.6848548188782]}, 'car_speed': '371', 'license_plate': {'bbox': [658.87939453125, 651.9542236328125, 725.9976196289062, 680.6212158203125], 'text': 'KM75IIF', 'bbox_score': 0.7160952687263489, 'text_score': 0.1009968165258482}}}, 116: {}, 117: {}, 118: {}, 119: {}, 120: {}, 121: {}, 122: {}, 123: {}, 124: {}, 125: {}, 126: {}, 127: {}, 128: {}, 129: {}, 130: {}, 131: {6.0: {'car': {'bbox': [414.6579834423475, 807.598567389786, 818.2123477094409, 1077.913421344336]}, 'car_speed': '124', 'license_plate': {'bbox': [561.256591796875, 1021.9818115234375, 656.5054931640625, 1049.6728515625], 'text': 'GX15OGJ', 'bbox_score': 0.7656121850013733, 'text_score': 0.3115616143300656}}}, 132: {}, 133: {}, 134: {}, 135: {}, 136: {}, 137: {}, 138: {}, 139: {}, 140: {}, 141: {}, 142: {8.0: {'car': {'bbox': [540.0972427490121, 568.236424294567, 796.4776774776774, 790.3864570966674]}, 'car_speed': '388', 'license_plate': {'bbox': [630.3065795898438, 707.55615234375, 700.7562255859375, 730.519775390625], 'text': 'KK05ZTX', 'bbox_score': 0.7055836319923401, 'text_score': 0.27947113099152276}}}, 143: {}, 144: {}, 145: {}, 146: {}, 147: {}, 148: {}, 149: {}, 150: {}, 151: {}, 152: {}, 153: {}, 154: {}, 155: {1.0: {'car': {'bbox': [1022.4227369957053, 645.4223486400052, 1333.8316929510238, 904.331175294399]}, 'car_speed': '149', 'license_plate': {'bbox': [1149.4775390625, 820.7896728515625, 1235.6898193359375, 846.6148681640625], 'text': 'AP05JEO', 'bbox_score': 0.34178102016448975, 'text_score': 0.6791577696123613}}}, 156: {}, 157: {}, 158: {}, 159: {8.0: {'car': {'bbox': [517.3391352551346, 595.4822835350626, 785.0087822272717, 829.4350736774425]}, 'car_speed': '360', 'license_plate': {'bbox': [608.2694702148438, 742.4888305664062, 693.7804565429688, 771.7714233398438], 'text': 'KH05ZZK', 'bbox_score': 0.3559908866882324, 'text_score': 0.1962672654243778}}}, 160: {}, 161: {}, 162: {8.0: {'car': {'bbox': [515.2204111616476, 600.5612456021961, 783.9723416522223, 836.7346757083492]}, 'car_speed': '284', 'license_plate': {'bbox': [606.58154296875, 749.713623046875, 689.9468994140625, 777.46875], 'text': 'WH05ZTK', 'bbox_score': 0.7651057243347168, 'text_score': 0.1687049309998234}}}, 163: {8.0: {'car': {'bbox': [513.0748948810103, 602.7170759116108, 784.0363985326685, 839.245026251791]}, 'car_speed': '231', 'license_plate': {'bbox': [607.9934692382812, 755.1846923828125, 689.35693359375, 778.3792114257812], 'text': 'KH05ZTX', 'bbox_score': 0.7437507510185242, 'text_score': 0.31365934886799307}}}, 164: {}, 165: {8.0: {'car': {'bbox': [509.57242740044614, 607.2224321666051, 783.0432536178633, 844.036280963342]}, 'car_speed': '200', 'license_plate': {'bbox': [602.9496459960938, 762.71044921875, 685.8387451171875, 783.2574462890625], 'text': 'KH05ZIK', 'bbox_score': 0.5974886417388916, 'text_score': 0.3057695226162196}}}, 166: {}, 167: {1.0: {'car': {'bbox': [1030.2343244433607, 674.285985598114, 1342.2659940135984, 944.2055968874434]}, 'car_speed': '195', 'license_plate': {'bbox': [1155.1722412109375, 854.9243774414062, 1231.8516845703125, 873.2858276367188], 'text': 'AP05JEC', 'bbox_score': 0.35580572485923767, 'text_score': 0.22506595341657015}}}, 168: {}, 169: {}, 170: {}, 171: {}, 172: {}, 173: {}, 174: {}, 175: {}, 176: {}, 177: {}, 178: {8.0: {'car': {'bbox': [498.6124221778325, 639.3796355032939, 778.5756822963299, 877.5854999949606]}, 'car_speed': '213', 'license_plate': {'bbox': [592.8748168945312, 789.468017578125, 677.7035522460938, 820.053955078125], 'text': 'TN05ZZX', 'bbox_score': 0.6320916414260864, 'text_score': 0.08495434526403957}}}, 179: {8.0: {'car': {'bbox': [496.3376919025684, 640.4879690306901, 776.0811934468679, 880.1171974730195]}, 'car_speed': '189', 'license_plate': {'bbox': [599.9631958007812, 797.2252807617188, 675.4798583984375, 822.2169799804688], 'text': 'ZH05ZZX', 'bbox_score': 0.6273050308227539, 'text_score': 0.017908931766015664}}}, 180: {8.0: {'car': {'bbox': [494.31611953256515, 641.4107267368335, 774.0781123534807, 883.2117644202266]}, 'car_speed': '171', 'license_plate': {'bbox': [590.7825927734375, 798.5839233398438, 674.51708984375, 826.0259399414062], 'text': 'RH05ZZK', 'bbox_score': 0.7850386500358582, 'text_score': 0.4503141113248251}}}, 181: {8.0: {'car': {'bbox': [493.34996990216837, 643.5908420626396, 773.3164910316866, 886.0582049545429]}, 'car_speed': '156', 'license_plate': {'bbox': [587.7005004882812, 795.5914916992188, 675.8494873046875, 827.0607299804688], 'text': 'KH05ZZR', 'bbox_score': 0.7898342609405518, 'text_score': 0.33554136655126127}}}, 182: {8.0: {'car': {'bbox': [492.1275052686322, 647.3477545177623, 772.2603937110703, 890.689907557673]}, 'car_speed': '143', 'license_plate': {'bbox': [594.4081420898438, 802.1588745117188, 673.9229736328125, 829.7023315429688], 'text': 'RH05ZZK', 'bbox_score': 0.7905105948448181, 'text_score': 0.15607434631749853}}}, 183: {}, 184: {}, 185: {8.0: {'car': {'bbox': [487.7477461527725, 653.915889523006, 767.8000573417852, 900.3685810789066]}, 'car_speed': '137', 'license_plate': {'bbox': [586.2530517578125, 811.4443359375, 673.9052734375, 838.1455078125], 'text': 'RH05ZZK', 'bbox_score': 0.4057205021381378, 'text_score': 0.15681906183454866}}}, 186: {8.0: {'car': {'bbox': [487.5359662945519, 656.8746038624993, 768.160444095593, 904.4800185212302]}, 'car_speed': '129', 'license_plate': {'bbox': [585.2886352539062, 814.7637329101562, 671.63671875, 843.7123413085938], 'text': 'MN05ZZK', 'bbox_score': 0.5691152215003967, 'text_score': 0.2381469065832256}}}, 187: {1.0: {'car': {'bbox': [1045.9278427973259, 729.4747917440495, 1383.035366708953, 1014.1852440462912]}, 'car_speed': '283', 'license_plate': {'bbox': [1176.3604736328125, 920.2267456054688, 1255.3338623046875, 944.1557006835938], 'text': 'AP05JEC', 'bbox_score': 0.3897472620010376, 'text_score': 0.8384824674150748}}}, 188: {8.0: {'car': {'bbox': [483.4766371006691, 660.6387822391126, 766.3232771853383, 911.1604212378512]}, 'car_speed': '123', 'license_plate': {'bbox': [583.5418701171875, 821.5631713867188, 670.88427734375, 849.3031005859375], 'text': 'RN05ZZX', 'bbox_score': 0.8165420293807983, 'text_score': 0.21980880502405017}}, 1.0: {'car': {'bbox': [1047.3848285810077, 733.1422274611905, 1386.5510494655305, 1018.6021676368555]}, 'car_speed': '220', 'license_plate': {'bbox': [1173.3875732421875, 926.7095947265625, 1256.4156494140625, 948.2969970703125], 'text': 'AP05JEC', 'bbox_score': 0.4945102632045746, 'text_score': 0.6663288081240191}}}, 189: {8.0: {'car': {'bbox': [480.249475358617, 664.3676797105778, 766.5036502556495, 915.373368042462]}, 'car_speed': '117', 'license_plate': {'bbox': [579.3924560546875, 822.6492919921875, 668.2540283203125, 851.4510498046875], 'text': 'RH05ZZK', 'bbox_score': 0.7936335802078247, 'text_score': 0.7981645450780812}}, 1.0: {'car': {'bbox': [1046.6681077284907, 736.9468084306994, 1386.8406652803124, 1022.6528418288298]}, 'car_speed': '181', 'license_plate': {'bbox': [1169.76318359375, 928.7467041015625, 1271.614501953125, 955.4692993164062], 'text': 'AP05JEO', 'bbox_score': 0.7661332488059998, 'text_score': 0.2820369925676699}}}, 190: {}, 191: {1.0: {'car': {'bbox': [1044.1846181585174, 743.1503434014243, 1386.8275190325116, 1030.7934425396188]}, 'car_speed': '159', 'license_plate': {'bbox': [1170.6402587890625, 937.130859375, 1272.1949462890625, 965.81689453125], 'text': 'AP05JEO', 'bbox_score': 0.34036797285079956, 'text_score': 0.6136308277446125}}}, 192: {}, 193: {}, 194: {}, 195: {}, 196: {}, 197: {}, 198: {1.0: {'car': {'bbox': [1047.6515682957356, 765.251747376896, 1401.903796547018, 1057.8229996813584]}, 'car_speed': '161', 'license_plate': {'bbox': [1181.6104736328125, 964.0909423828125, 1285.2257080078125, 992.21337890625], 'text': 'AP05JEO', 'bbox_score': 0.5772363543510437, 'text_score': 0.2734537226243061}}}, 199: {1.0: {'car': {'bbox': [1049.2493626790379, 768.2001593895903, 1406.639670835676, 1061.3928603999134]}, 'car_speed': '145', 'license_plate': {'bbox': [1177.6556396484375, 969.3513793945312, 1286.4642333984375, 994.6726684570312], 'text': 'AP05JEO', 'bbox_score': 0.36987724900245667, 'text_score': 0.5292007117821277}}}, 200: {}, 201: {}, 202: {}, 203: {}, 204: {1.0: {'car': {'bbox': [1051.6217300210587, 782.2864441872314, 1418.4156372271464, 1075.5040111561834]}, 'car_speed': '141', 'license_plate': {'bbox': [1184.7952880859375, 990.0324096679688, 1297.32275390625, 1019.0203857421875], 'text': 'AP05JEQ', 'bbox_score': 0.6294832825660706, 'text_score': 0.40179873300550706}}}, 205: {}, 206: {1.0: {'car': {'bbox': [1050.6760364469035, 788.3872108424988, 1421.7257749732146, 1077.819246493215]}, 'car_speed': '130', 'license_plate': {'bbox': [1185.75146484375, 998.6322021484375, 1287.0179443359375, 1024.732177734375], 'text': 'AP05JEO', 'bbox_score': 0.5754414796829224, 'text_score': 0.17079251100550147}}}, 207: {1.0: {'car': {'bbox': [1050.6294844998365, 792.012954787921, 1424.6697749963173, 1078.3336839820927]}, 'car_speed': '119', 'license_plate': {'bbox': [1189.7786865234375, 1001.9678344726562, 1302.8475341796875, 1034.8077392578125], 'text': 'AP05JEO', 'bbox_score': 0.5427210330963135, 'text_score': 0.25672875440289444}}}, 208: {}, 209: {}, 210: {}, 211: {}, 212: {}, 213: {}, 214: {}, 215: {}, 216: {}, 217: {}, 218: {}, 219: {}, 220: {}, 221: {}, 222: {}, 223: {}, 224: {}, 225: {}, 226: {}, 227: {}, 228: {}, 229: {}, 230: {}, 231: {}, 232: {}, 233: {}, 234: {}, 235: {}, 236: {}, 237: {}, 238: {}, 239: {}, 240: {}, 241: {}, 242: {}, 243: {}, 244: {}, 245: {}, 246: {}, 247: {}, 248: {}, 249: {}, 250: {}, 251: {}, 252: {}, 253: {}, 254: {}, 255: {}, 256: {}, 257: {}, 258: {}, 259: {}, 260: {}, 261: {}, 262: {}, 263: {}, 264: {}, 265: {}, 266: {}, 267: {}, 268: {}, 269: {}, 270: {}, 271: {}, 272: {}, 273: {}, 274: {}, 275: {}, 276: {}, 277: {}, 278: {}, 279: {}, 280: {}, 281: {}, 282: {14.0: {'car': {'bbox': [430.7031529146813, 776.3696369251816, 764.6515967203011, 1071.07758553248]}, 'car_speed': '120', 'license_plate': {'bbox': [558.161865234375, 977.7589111328125, 648.4338989257812, 1007.1537475585938], 'text': 'FJ14ZHY', 'bbox_score': 0.7726970911026001, 'text_score': 0.6854983803304893}}}, 283: {}, 284: {}, 285: {}, 286: {}, 287: {}, 288: {14.0: {'car': {'bbox': [421.7842705368697, 791.8765701360235, 761.5550124556195, 1077.7049483313244]}, 'car_speed': '907', 'license_plate': {'bbox': [542.7487182617188, 1000.552734375, 640.46630859375, 1032.8583984375], 'text': 'FJ14ZHY', 'bbox_score': 0.7146000266075134, 'text_score': 0.6647482119849303}}}, 289: {}, 290: {14.0: {'car': {'bbox': [423.6057072320627, 798.2762497249638, 762.742332113548, 1077.016646700486]}, 'car_speed': '798', 'license_plate': {'bbox': [537.635986328125, 1006.7369384765625, 637.7538452148438, 1042.465576171875], 'text': 'FJ14ZHY', 'bbox_score': 0.7243423461914062, 'text_score': 0.5857446595624058}}}, 291: {}} + + last_data = [] + + + cleaned_data = {k: v for k, v in additional_data.items() if v != {}} + + for car_id, data in cleaned_data.items(): + for _, entry in data.items(): + if "car_speed" in entry and "license_plate" in entry and "text" in entry["license_plate"]: + _j = { + "car_id": car_id, + "car_speed": entry["car_speed"], + "license_plate": entry["license_plate"]["text"] + } + last_data.append(_j) + + + return render(request , "index2.html" , {'last_data': last_data}) + + + +def show(request) : + return render(request ,"show.html") + + +def data_found(request) : + return render(request , "404.html") + + +def contact(request) : + return render(request , "contact.html") \ No newline at end of file diff --git a/carssp/__init__.py b/carssp/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/carssp/__pycache__/__init__.cpython-310.pyc b/carssp/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..9fadf73 Binary files /dev/null and b/carssp/__pycache__/__init__.cpython-310.pyc differ diff --git a/carssp/__pycache__/settings.cpython-310.pyc b/carssp/__pycache__/settings.cpython-310.pyc new file mode 100644 index 0000000..879c51e Binary files /dev/null and b/carssp/__pycache__/settings.cpython-310.pyc differ diff --git a/carssp/__pycache__/urls.cpython-310.pyc b/carssp/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000..615d86a Binary files /dev/null and b/carssp/__pycache__/urls.cpython-310.pyc differ diff --git a/carssp/__pycache__/wsgi.cpython-310.pyc b/carssp/__pycache__/wsgi.cpython-310.pyc new file mode 100644 index 0000000..5e4ced2 Binary files /dev/null and b/carssp/__pycache__/wsgi.cpython-310.pyc differ diff --git a/carssp/asgi.py b/carssp/asgi.py new file mode 100644 index 0000000..37d231e --- /dev/null +++ b/carssp/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for carssp project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.0/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'carssp.settings') + +application = get_asgi_application() diff --git a/carssp/settings.py b/carssp/settings.py new file mode 100644 index 0000000..2a9431a --- /dev/null +++ b/carssp/settings.py @@ -0,0 +1,132 @@ +""" +Django settings for carssp project. + +Generated by 'django-admin startproject' using Django 5.0.6. + +For more information on this file, see +https://docs.djangoproject.com/en/5.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/5.0/ref/settings/ +""" + +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-1v8eoj_h*qygne$$6nok2pne)jx!d!r9h^3du3u_!p-0e3bols' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'base' , +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'carssp.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'carssp.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/5.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/5.0/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/5.0/howto/static-files/ + + +import os + + +STATIC_URL = '/static/' +STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')] + +MEDIA_URL = '/media/' +MEDIA_ROOT = os.path.join(BASE_DIR, 'media/') + +# Default primary key field type +# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/carssp/urls.py b/carssp/urls.py new file mode 100644 index 0000000..6bfb2f9 --- /dev/null +++ b/carssp/urls.py @@ -0,0 +1,11 @@ +from django.conf import settings +from django.contrib import admin +from django.urls import path , include +from django.conf.urls.static import static +urlpatterns = [ + path('admin/', admin.site.urls), + path('' ,include("base.urls") ) +] + +if settings.DEBUG: + urlpatterns += static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT) \ No newline at end of file diff --git a/carssp/wsgi.py b/carssp/wsgi.py new file mode 100644 index 0000000..9c2829c --- /dev/null +++ b/carssp/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for carssp project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.0/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'carssp.settings') + +application = get_wsgi_application() diff --git a/db.sqlite3 b/db.sqlite3 new file mode 100644 index 0000000..15f434a Binary files /dev/null and b/db.sqlite3 differ diff --git a/manage.py b/manage.py new file mode 100644 index 0000000..e6b07ae --- /dev/null +++ b/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'carssp.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/static/img/Mail-rafiki.svg b/static/img/Mail-rafiki.svg new file mode 100644 index 0000000..a3cbb6d --- /dev/null +++ b/static/img/Mail-rafiki.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/img/Online tech talks-rafiki.svg b/static/img/Online tech talks-rafiki.svg new file mode 100644 index 0000000..7c6e645 --- /dev/null +++ b/static/img/Online tech talks-rafiki.svg @@ -0,0 +1 @@ + diff --git a/static/img/django.svg b/static/img/django.svg new file mode 100644 index 0000000..05b253f --- /dev/null +++ b/static/img/django.svg @@ -0,0 +1 @@ + \ No newline at end of file