From c52a1fbd02432252744a96639ea38f35b8cbd151 Mon Sep 17 00:00:00 2001 From: Sabyasachi Kumar <2100031988@kluniversity.in> Date: Sun, 13 Oct 2024 08:41:21 +0530 Subject: [PATCH 1/3] Update index.js --- FaceRec/static/index.js | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) 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"); }); From 3f99c7c40cca7176577dd32287bc628c6d33287d Mon Sep 17 00:00:00 2001 From: Sabyasachi Kumar <2100031988@kluniversity.in> Date: Sun, 13 Oct 2024 08:42:16 +0530 Subject: [PATCH 2/3] Update main.py --- main.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 9c962c1..978bcc2 100644 --- a/main.py +++ b/main.py @@ -1,12 +1,31 @@ from __future__ import annotations - 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) From 1a6f19bfc199e41c052d1c401353ca9adc82cf01 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 13 Oct 2024 05:35:19 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- main.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 978bcc2..c8eb701 100644 --- a/main.py +++ b/main.py @@ -1,16 +1,20 @@ from __future__ import annotations + from concurrent.futures import ThreadPoolExecutor -import cv2 + +import cv2 import numpy as np + from API import run_fastapi_app from FaceRec.app.main import run_flask + def preprocess_image(image_path: str) -> np.ndarray: image = cv2.imread(image_path) hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV) - value = 40 + value = 40 h, s, v = cv2.split(hsv) v = cv2.add(v, value) final_hsv = cv2.merge((h, s, v)) @@ -18,14 +22,15 @@ def preprocess_image(image_path: str) -> np.ndarray: (h, w) = image.shape[:2] center = (w // 2, h // 2) - M = cv2.getRotationMatrix2D(center, angle=10, scale=1.0) + 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') - + preprocessed_image = preprocess_image("path_to_image.jpg") + with ThreadPoolExecutor(max_workers=2) as executor: executor.submit(run_flask) executor.submit(run_fastapi_app)