probably works. Added possibility changing associated numbers
BIN
bibrecognition/images/bib_01_i38EFwg.jpg
Normal file
After Width: | Height: | Size: 456 KiB |
BIN
bibrecognition/images/bib_02.jpg
Normal file
After Width: | Height: | Size: 99 KiB |
BIN
bibrecognition/images/bib_03_G9AxFQY.jpg
Normal file
After Width: | Height: | Size: 140 KiB |
BIN
bibrecognition/images/bib_04_mimQ6LJ.jpg
Normal file
After Width: | Height: | Size: 528 KiB |
BIN
bibrecognition/images/bib_05.jpg
Normal file
After Width: | Height: | Size: 446 KiB |
BIN
bibrecognition/images/bib_05_kQ2mqaw.jpg
Normal file
After Width: | Height: | Size: 446 KiB |
BIN
bibrecognition/images/bib_05_roPy7Ha.jpg
Normal file
After Width: | Height: | Size: 446 KiB |
@ -11,5 +11,14 @@ class PhotoForm(forms.Form):
|
|||||||
|
|
||||||
class SearchForm(forms.Form):
|
class SearchForm(forms.Form):
|
||||||
zawody = forms.ModelChoiceField(
|
zawody = forms.ModelChoiceField(
|
||||||
queryset=Competitions.objects.all(), to_field_name="comp_slug")
|
queryset=Competitions.objects.filter(status="published"), to_field_name="comp_slug")
|
||||||
numer = forms.DecimalField(decimal_places=0)
|
numer = forms.DecimalField(decimal_places=0)
|
||||||
|
|
||||||
|
|
||||||
|
class ChangeForm(forms.Form):
|
||||||
|
zawody = forms.ModelChoiceField(
|
||||||
|
queryset=Competitions.objects.all(), to_field_name="comp_slug")
|
||||||
|
|
||||||
|
|
||||||
|
class ChangeIDForm(forms.Form):
|
||||||
|
numerki = forms.CharField()
|
||||||
|
@ -72,7 +72,7 @@ def decode_predictions(scores, geometry):
|
|||||||
|
|
||||||
|
|
||||||
def findNumber(url):
|
def findNumber(url):
|
||||||
image = cv2.imread(url)
|
image = cv2.imread("./"+url)
|
||||||
orig = image.copy()
|
orig = image.copy()
|
||||||
(origH, origW) = image.shape[:2]
|
(origH, origW) = image.shape[:2]
|
||||||
(newW, newH) = (320,320)
|
(newW, newH) = (320,320)
|
||||||
|
@ -17,7 +17,7 @@ class Competitions(models.Model):
|
|||||||
class Photo(models.Model):
|
class Photo(models.Model):
|
||||||
comp_id = models.ForeignKey(Competitions, on_delete=models.CASCADE)
|
comp_id = models.ForeignKey(Competitions, on_delete=models.CASCADE)
|
||||||
name = models.CharField(max_length=100, default='Zdjecie')
|
name = models.CharField(max_length=100, default='Zdjecie')
|
||||||
image = models.ImageField(upload_to='images/', default='placeholder.jpg')
|
image = models.ImageField(upload_to='./', default='placeholder.jpg')
|
||||||
# url = models.CharField(max_length=50)
|
# url = models.CharField(max_length=50)
|
||||||
objects = PhotoManager()
|
objects = PhotoManager()
|
||||||
|
|
||||||
|
33
bibrecognition/imguploader/templates/change.html
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Search Photos</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
{% if form %}
|
||||||
|
<form action="/change" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form }}
|
||||||
|
<input type="submit" value="Submit">
|
||||||
|
</form>
|
||||||
|
{% endif %}
|
||||||
|
{% if meta %}
|
||||||
|
<ul>
|
||||||
|
{% for n in meta %}
|
||||||
|
<li><img src="images/{{ n.0 }}" />
|
||||||
|
<div>
|
||||||
|
{% for nr in n.1 %}
|
||||||
|
<p>{{ nr }}</p>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
30
bibrecognition/imguploader/templates/changeid.html
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Search Photos</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
{% if foto %}
|
||||||
|
<img src="{{ foto }}" />
|
||||||
|
<p>Znalezione wartości:</p>
|
||||||
|
<span>
|
||||||
|
{% for n in numery %}
|
||||||
|
{{ n }},
|
||||||
|
{% endfor %}
|
||||||
|
<p>Nowe wartości (po przecinku): </p>
|
||||||
|
<form action="/change/{{ photoid }}" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form }}
|
||||||
|
<input type="submit" value="Submit">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
@ -9,7 +9,8 @@
|
|||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
Zalogowany 😎 <br />
|
Zalogowany 😎 <br />
|
||||||
<a href="{% url 'upload' %}">Załaduj zdjęcia</a><br />
|
<a href="{% url 'upload' %}">Załaduj zdjęcia</a><br />
|
||||||
<a href="{% url 'search' %}">Przeszukaj bazę</a>
|
<a href="{% url 'search' %}">Przeszukaj bazę</a><br />
|
||||||
|
<a href="{% url 'change' %}">Koryguj</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
Gość 🏃♀️<br />
|
Gość 🏃♀️<br />
|
||||||
<a href="{% url 'search' %}">Przeszukaj bazę</a>
|
<a href="{% url 'search' %}">Przeszukaj bazę</a>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
{% if foto %}
|
{% if foto %}
|
||||||
<ul>
|
<ul>
|
||||||
{% for n in foto %}
|
{% for n in foto %}
|
||||||
<li><img src="{{ n }}" /></li>
|
<li><img src="images/{{ n }}" /></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -8,6 +8,8 @@ urlpatterns = [
|
|||||||
path('', views.index, name="index"),
|
path('', views.index, name="index"),
|
||||||
path('upload', views.uploadPhotos, name="upload"),
|
path('upload', views.uploadPhotos, name="upload"),
|
||||||
path('search', views.searchPhotos, name="search"),
|
path('search', views.searchPhotos, name="search"),
|
||||||
|
path('change', views.changePhotos, name="change"),
|
||||||
|
path('change/<int:photo>', views.changePhotoID, name="changeid"),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@ from django.shortcuts import render
|
|||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from .forms import PhotoForm
|
from .forms import PhotoForm
|
||||||
from .forms import SearchForm
|
from .forms import SearchForm
|
||||||
|
from .forms import ChangeForm
|
||||||
|
from .forms import ChangeIDForm
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
|
|
||||||
from .models import PhotoManager
|
from .models import PhotoManager
|
||||||
@ -55,7 +57,7 @@ def searchPhotos(request):
|
|||||||
form = SearchForm(request.POST)
|
form = SearchForm(request.POST)
|
||||||
comp = request.POST['zawody']
|
comp = request.POST['zawody']
|
||||||
numer = request.POST['numer']
|
numer = request.POST['numer']
|
||||||
print(request)
|
# print(request)
|
||||||
|
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
allFotos = []
|
allFotos = []
|
||||||
@ -76,6 +78,7 @@ def searchPhotos(request):
|
|||||||
return render(request, 'search.html', {'foto': imgUrls})
|
return render(request, 'search.html', {'foto': imgUrls})
|
||||||
else:
|
else:
|
||||||
print('no ni ma')
|
print('no ni ma')
|
||||||
|
return HttpResponseRedirect('/failed/')
|
||||||
|
|
||||||
return HttpResponseRedirect('/success/')
|
return HttpResponseRedirect('/success/')
|
||||||
else:
|
else:
|
||||||
@ -85,3 +88,75 @@ def searchPhotos(request):
|
|||||||
form = SearchForm()
|
form = SearchForm()
|
||||||
return render(request, 'search.html', {'form': form})
|
return render(request, 'search.html', {'form': form})
|
||||||
# return HttpResponse("Hello, world. This is imageUploader")
|
# return HttpResponse("Hello, world. This is imageUploader")
|
||||||
|
|
||||||
|
|
||||||
|
def changePhotos(request):
|
||||||
|
if request.method == 'POST':
|
||||||
|
form = ChangeForm(request.POST)
|
||||||
|
comp = request.POST['zawody']
|
||||||
|
imgMeta = []
|
||||||
|
if form.is_valid():
|
||||||
|
zawody = Competitions.objects.get(comp_slug=comp)
|
||||||
|
try:
|
||||||
|
zdjecia = Photo.objects.filter(
|
||||||
|
comp_id=zawody)
|
||||||
|
except Photo.DoesNotExist:
|
||||||
|
zdjecia = None
|
||||||
|
|
||||||
|
if( zdjecia ):
|
||||||
|
for zdjecie in zdjecia:
|
||||||
|
meta = []
|
||||||
|
pm = PhotoMeta.objects.filter(photo_id=zdjecie)
|
||||||
|
meta.append(zdjecie.image.name)
|
||||||
|
numery = []
|
||||||
|
for numer in pm:
|
||||||
|
numery.append(numer.meta_value)
|
||||||
|
meta.append(numery)
|
||||||
|
imgMeta.append(meta)
|
||||||
|
|
||||||
|
return render(request, 'change.html', {'meta': imgMeta})
|
||||||
|
else:
|
||||||
|
print('no ni ma')
|
||||||
|
return HttpResponseRedirect('/failed/')
|
||||||
|
|
||||||
|
else:
|
||||||
|
return HttpResponseRedirect('/failed/')
|
||||||
|
else:
|
||||||
|
form = ChangeForm()
|
||||||
|
|
||||||
|
return render(request, 'change.html', {'form': form})
|
||||||
|
|
||||||
|
|
||||||
|
def changePhotoID(request, photo):
|
||||||
|
if request.method == 'POST':
|
||||||
|
form = ChangeIDForm(request.POST)
|
||||||
|
meta = request.POST['numerki']
|
||||||
|
numerki = meta.split(',')
|
||||||
|
zdjecie = Photo.objects.get(pk=photo)
|
||||||
|
|
||||||
|
PhotoMeta.objects.filter(photo_id=zdjecie).delete()
|
||||||
|
for n in numerki:
|
||||||
|
n = n.strip()
|
||||||
|
pm = PhotoMeta(comp_id=zdjecie.comp_id, photo_id=zdjecie,
|
||||||
|
meta_key="detect_number", meta_value=n)
|
||||||
|
pm.save(force_insert=True)
|
||||||
|
|
||||||
|
return render(request, 'changeid.html')
|
||||||
|
else:
|
||||||
|
form = ChangeIDForm()
|
||||||
|
try:
|
||||||
|
zdjecie = Photo.objects.get(pk=photo)
|
||||||
|
except Photo.DoesNotExist:
|
||||||
|
zdjecie = None
|
||||||
|
|
||||||
|
if(zdjecie):
|
||||||
|
pm = PhotoMeta.objects.filter(photo_id=zdjecie)
|
||||||
|
foto = zdjecie.image.url
|
||||||
|
numery = []
|
||||||
|
for nr in pm:
|
||||||
|
numery.append(nr.meta_value)
|
||||||
|
else:
|
||||||
|
print('no ni ma')
|
||||||
|
return HttpResponseRedirect('/failed/')
|
||||||
|
|
||||||
|
return render(request, 'changeid.html', {'photoid':photo,'foto': foto, 'numery': numery, 'form': form})
|
||||||
|
BIN
imgs/bib_05.jpg
Normal file
After Width: | Height: | Size: 446 KiB |
BIN
imgs/bib_06.jpg
Normal file
After Width: | Height: | Size: 154 KiB |
BIN
imgs/bib_07.jpg
Normal file
After Width: | Height: | Size: 84 KiB |
BIN
imgs/bib_08.jpg
Normal file
After Width: | Height: | Size: 139 KiB |
BIN
imgs/bib_09.jpg
Normal file
After Width: | Height: | Size: 268 KiB |