Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions FaceRec/static/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@ $(document).ready(function () {
const Name = $("#Name").val();
const gender = $("#Gender").val();
const Department = $("#Department").val();

let image = document.getElementById('Image');
rotateImage(image, 10);

$.ajax({
type: "POST",
url: "/capture",
data: {"EmployeeCode":EmployeeCode,"Name": Name ,"gender":gender,"Department":Department}, // Send Title value in the request
data: {
"EmployeeCode": EmployeeCode,
"Name": Name,
"gender": gender,
"Department": Department
},
success: function (response) {
console.log(response)
console.log(response);
updateImage();
enableImage();
},
Expand All @@ -20,13 +29,17 @@ $(document).ready(function () {
});
});

function rotateImage(imageElement, degree) {
imageElement.style.transform = `rotate(${degree}deg)`;
}

$(document).ready(function () {
$("#captureButton1").on("click", function () {
$.ajax({
type: "POST",
url: "/capturing",
success: function (response) {
console.log(response)
console.log(response);
updateImage();
enableImage();
},
Expand All @@ -37,26 +50,23 @@ $(document).ready(function () {
});
});






function updateImage(){
function updateImage() {
var img = document.getElementById('Image');
img.src = 'static/Images/uploads/final.png';
alert(img.src)
alert(img.src);
}

function enableImage(){
function enableImage() {
var imgElement = document.getElementById('Image');
imgElement.removeAttribute('hidden');
var uploadElement = document.getElementById('Upload');
uploadElement.removeAttribute('hidden');
}

myButton.addEventListener("click", function () {
myPopup.classList.add("show");
});

closePopup.addEventListener("click", function () {
myPopup.classList.remove("show");
});
Expand Down
26 changes: 25 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,35 @@

from concurrent.futures import ThreadPoolExecutor

import cv2
import numpy as np

from API import run_fastapi_app
from FaceRec.app.main import run_flask

# Multithreading used to start both FastAPI and Flask apps at the same time.

def preprocess_image(image_path: str) -> np.ndarray:

image = cv2.imread(image_path)

hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
value = 40
h, s, v = cv2.split(hsv)
v = cv2.add(v, value)
final_hsv = cv2.merge((h, s, v))
image = cv2.cvtColor(final_hsv, cv2.COLOR_HSV2BGR)

(h, w) = image.shape[:2]
center = (w // 2, h // 2)
M = cv2.getRotationMatrix2D(center, angle=10, scale=1.0)
image = cv2.warpAffine(image, M, (w, h))

return image


if __name__ == "__main__":
preprocessed_image = preprocess_image("path_to_image.jpg")

with ThreadPoolExecutor(max_workers=2) as executor:
executor.submit(run_flask)
executor.submit(run_fastapi_app)