diff --git a/FaceRec/static/index.js b/FaceRec/static/index.js index 5e6b76a..e8fd018 100644 --- a/FaceRec/static/index.js +++ b/FaceRec/static/index.js @@ -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(); }, @@ -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(); }, @@ -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"); }); diff --git a/main.py b/main.py index 9c962c1..c8eb701 100644 --- a/main.py +++ b/main.py @@ -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)