├── README.md ├── RealTime_Face_Detection.ipynb ├── face_recog ├── final knn model_yash.ipynb ├── final knn model_yash_phonecam.ipynb ├── known_people │ └── test.jpg ├── models │ └── test.jpg ├── test │ └── test.jpg └── unknown_pictures │ └── test.jpg └── main ├── Attendance.csv ├── adminLogin.html ├── adminScreen.html ├── assets └── models │ └── trained_knn_model.clf ├── css └── materialize.min.css ├── dataEntry.html ├── etc ├── data1.html ├── data2.html └── data3.html ├── facultyLogin.html ├── img ├── dp.png ├── icon.png └── user.png ├── index.html ├── js ├── adminLogin.js ├── adminScreen.js ├── data1.js ├── facultyLogin.js ├── jquery.js ├── materialize.min.js └── upload.js ├── main.js ├── package-lock.json ├── package.json └── py ├── camcap2.py ├── camcapture.py ├── capture.py ├── helper.txt ├── phoneCapture.py └── train.py /README.md: -------------------------------------------------------------------------------- 1 | # MozoHack 2019 2 | Above is a re-upload of everything that my team and I worked on and developed at the Mozohack 24-Hour Hackathon. This is a working model of our product, which has an AI assisted automated attendance system. Using basic hardware elements such as a 720 camera, institutions and offices can use our services to automate the attendance process. 3 | 4 | Instructions: 5 | 6 | Install and unpack electron inside the /main 7 | Open Terminal and run electron using npm start 8 | Default logins credentials are: 9 | staff@mozohack.com | mozostaff 10 | admin@mozohack.com | mozoadmin 11 | All codes are equipped with appropriate logs for debug. Deep comments will be added soon. 12 | 13 | Email for issues. 14 | -------------------------------------------------------------------------------- /RealTime_Face_Detection.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import cv2\n", 10 | "import numpy as np\n", 11 | "from matplotlib import pyplot as plt\n", 12 | "%matplotlib inline\n", 13 | "\n", 14 | "face_cascade = cv2.CascadeClassifier(\"C:/Users/Choudhary/haarcascades/haarcascade_frontalface_default.xml\")\n", 15 | "\n", 16 | "cap = cv2.VideoCapture(0)\n", 17 | "cap.set(cv2.CAP_PROP_FPS, 100)\n", 18 | "rat, frame = cap.read()\n", 19 | "while(True):\n", 20 | " rat, frame = cap.read()\n", 21 | " gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)\n", 22 | "\n", 23 | " faces = face_cascade.detectMultiScale(gray, 1.1, 4)\n", 24 | " for (x,y,w,h) in faces:\n", 25 | " cv2.rectangle(frame,(x,y),(x+w,y+h),(255,0,0),2)\n", 26 | " roi_gray = gray[y:y+h, x:x+w]\n", 27 | " roi_color = frame[y:y+h, x:x+w]\n", 28 | " crop_img = frame[y:y+h, x:x+w]\n", 29 | " cv2.imshow('img',frame)\n", 30 | " if cv2.waitKey(1) & 0xFF == ord('q'):\n", 31 | " break\n", 32 | "\n", 33 | "\n", 34 | "cap.release() \n", 35 | "cv2.destroyAllWindows()" 36 | ] 37 | }, 38 | { 39 | "cell_type": "code", 40 | "execution_count": null, 41 | "metadata": {}, 42 | "outputs": [], 43 | "source": [] 44 | } 45 | ], 46 | "metadata": { 47 | "kernelspec": { 48 | "display_name": "Python 3", 49 | "language": "python", 50 | "name": "python3" 51 | }, 52 | "language_info": { 53 | "codemirror_mode": { 54 | "name": "ipython", 55 | "version": 3 56 | }, 57 | "file_extension": ".py", 58 | "mimetype": "text/x-python", 59 | "name": "python", 60 | "nbconvert_exporter": "python", 61 | "pygments_lexer": "ipython3", 62 | "version": "3.6.8" 63 | } 64 | }, 65 | "nbformat": 4, 66 | "nbformat_minor": 2 67 | } 68 | -------------------------------------------------------------------------------- /face_recog/final knn model_yash.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 4, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import math\n", 10 | "import cv2\n", 11 | "from sklearn import neighbors\n", 12 | "import numpy as np\n", 13 | "import pandas as pd\n", 14 | "import os\n", 15 | "import os.path\n", 16 | "import pickle\n", 17 | "from PIL import Image, ImageDraw\n", 18 | "import face_recognition\n", 19 | "from face_recognition.face_recognition_cli import image_files_in_folder\n", 20 | "curd = os.getcwd()\n", 21 | "try: \n", 22 | " os.mkdir(\"{}/known_people\".format(curd))\n", 23 | "except:\n", 24 | " pass\n", 25 | "try: \n", 26 | " os.mkdir(\"{}/models\".format(curd))\n", 27 | "except:\n", 28 | " pass\n", 29 | "try: \n", 30 | " os.mkdir(\"{}/test\".format(curd))\n", 31 | "except:\n", 32 | " pass\n", 33 | "try: \n", 34 | " os.mkdir(\"{}/unknown_pictures\".format(curd))\n", 35 | "except:\n", 36 | " pass\n", 37 | "names=[]" 38 | ] 39 | }, 40 | { 41 | "cell_type": "code", 42 | "execution_count": 11, 43 | "metadata": {}, 44 | "outputs": [], 45 | "source": [ 46 | "ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg'}" 47 | ] 48 | }, 49 | { 50 | "cell_type": "code", 51 | "execution_count": 12, 52 | "metadata": {}, 53 | "outputs": [], 54 | "source": [ 55 | "def train(train_dir, model_save_path=None, n_neighbors=None, knn_algo='ball_tree', verbose=False):\n", 56 | " \n", 57 | " X = []\n", 58 | " y = []\n", 59 | "\n", 60 | " for class_dir in os.listdir(train_dir):\n", 61 | " if not os.path.isdir(os.path.join(train_dir, class_dir)):\n", 62 | " continue\n", 63 | "\n", 64 | " for img_path in image_files_in_folder(os.path.join(train_dir, class_dir)):\n", 65 | " image = face_recognition.load_image_file(img_path)\n", 66 | " face_bounding_boxes = face_recognition.face_locations(image)\n", 67 | "\n", 68 | " if len(face_bounding_boxes) != 1:\n", 69 | " if verbose:\n", 70 | " print(\"Image {} not suitable for training: {}\".format(img_path, \"Didn't find a face\" if len(face_bounding_boxes) < 1 else \"Found more than one face\"))\n", 71 | " else:\n", 72 | " X.append(face_recognition.face_encodings(image, known_face_locations=face_bounding_boxes)[0])\n", 73 | " y.append(class_dir)\n", 74 | "\n", 75 | " if n_neighbors is None:\n", 76 | " n_neighbors = int(round(math.sqrt(len(X))))\n", 77 | " if verbose:\n", 78 | " print(\"Chose n_neighbors automatically:\", n_neighbors)\n", 79 | "\n", 80 | " knn_clf = neighbors.KNeighborsClassifier(n_neighbors=n_neighbors, algorithm=knn_algo, weights='distance')\n", 81 | " knn_clf.fit(X, y)\n", 82 | "\n", 83 | " if model_save_path is not None:\n", 84 | " with open(model_save_path, 'wb') as f:\n", 85 | " pickle.dump(knn_clf, f)\n", 86 | "\n", 87 | " return knn_clf" 88 | ] 89 | }, 90 | { 91 | "cell_type": "code", 92 | "execution_count": 13, 93 | "metadata": {}, 94 | "outputs": [], 95 | "source": [ 96 | "\n", 97 | "def predict(frame, knn_clf=None, model_path=None, distance_threshold=0.6):\n", 98 | " \n", 99 | "\n", 100 | " if knn_clf is None and model_path is None:\n", 101 | " raise Exception(\"Must supply knn classifier either thourgh knn_clf or model_path\")\n", 102 | "\n", 103 | " if knn_clf is None:\n", 104 | " with open(model_path, 'rb') as f:\n", 105 | " knn_clf = pickle.load(f)\n", 106 | "\n", 107 | " \n", 108 | " # X_img = face_recognition.load_image_file(X_img_path)\n", 109 | " X_img = frame\n", 110 | " X_face_locations = face_recognition.face_locations(X_img)\n", 111 | "\n", 112 | " if len(X_face_locations) == 0:\n", 113 | " return []\n", 114 | "\n", 115 | " faces_encodings = face_recognition.face_encodings(X_img, known_face_locations=X_face_locations)\n", 116 | "\n", 117 | " closest_distances = knn_clf.kneighbors(faces_encodings, n_neighbors=1)\n", 118 | " are_matches = [closest_distances[0][i][0] <= distance_threshold for i in range(len(X_face_locations))]\n", 119 | "\n", 120 | " return [(pred, loc) if rec else (\"unknown\", loc) for pred, loc, rec in zip(knn_clf.predict(faces_encodings), X_face_locations, are_matches)]\n" 121 | ] 122 | }, 123 | { 124 | "cell_type": "code", 125 | "execution_count": 14, 126 | "metadata": {}, 127 | "outputs": [], 128 | "source": [ 129 | "#my version\n", 130 | "def show_prediction_labels_on_image(frame, predictions):\n", 131 | " \n", 132 | " #pil_image = Image.open(img_path).convert(\"RGB\")\n", 133 | " pil_image = Image.fromarray(frame).convert(\"RGB\")\n", 134 | " draw = ImageDraw.Draw(pil_image)\n", 135 | "\n", 136 | " for name, (top, right, bottom, left) in predictions:\n", 137 | " draw.rectangle(((left, top), (right, bottom)), outline=(0, 0, 255))\n", 138 | "\n", 139 | " \n", 140 | " name = name.encode(\"UTF-8\")\n", 141 | "\n", 142 | " text_width, text_height = draw.textsize(name)\n", 143 | " draw.rectangle(((left, bottom - text_height - 10), (right, bottom)), fill=(0, 0, 255), outline=(0, 0, 255))\n", 144 | " draw.text((left + 6, bottom - text_height - 5), name, fill=(255, 255, 255, 255))\n", 145 | "\n", 146 | " del draw\n", 147 | "\n", 148 | " #pil_image.show()\n", 149 | " #cv2.imshow(\"frame\",pil_image)\n", 150 | " return np.asarray(pil_image)\n" 151 | ] 152 | }, 153 | { 154 | "cell_type": "code", 155 | "execution_count": null, 156 | "metadata": {}, 157 | "outputs": [], 158 | "source": [ 159 | "#Train data creator\n", 160 | "import cv2\n", 161 | "import numpy as np\n", 162 | "import time\n", 163 | "import os\n", 164 | "curd = os.getcwd()\n", 165 | "name = input()\n", 166 | "path = \"{}/known_people/{}\".format(curd,name)\n", 167 | "try: \n", 168 | " os.mkdir(path)\n", 169 | "except OSError: \n", 170 | " print (\"Creation of the directory %s failed\" % path)\n", 171 | "cap = cv2.VideoCapture(0)\n", 172 | "cap.set(cv2.CAP_PROP_FPS, 100)\n", 173 | "rat, frame = cap.read()\n", 174 | "\n", 175 | "count=0\n", 176 | "while count<10:\n", 177 | " \n", 178 | " rat, frame = cap.read()\n", 179 | " cv2.imwrite(\"{}/{}{}.jpg\".format(path,name,count), frame)\n", 180 | " count+=1\n", 181 | " cv2.imshow('img',frame)\n", 182 | " if cv2.waitKey(1) & 0xFF == ord('q'):\n", 183 | " break\n", 184 | " time.sleep(1) \n", 185 | "\n", 186 | "\n", 187 | "cap.release() \n", 188 | "cv2.destroyAllWindows()" 189 | ] 190 | }, 191 | { 192 | "cell_type": "code", 193 | "execution_count": 7, 194 | "metadata": {}, 195 | "outputs": [ 196 | { 197 | "name": "stdout", 198 | "output_type": "stream", 199 | "text": [ 200 | "Training KNN classifier...\n" 201 | ] 202 | }, 203 | { 204 | "name": "stderr", 205 | "output_type": "stream", 206 | "text": [ 207 | "C:\\Users\\Choudhary\\Anaconda3\\envs\\mlkit\\lib\\site-packages\\PIL\\Image.py:969: UserWarning: Palette images with Transparency expressed in bytes should be converted to RGBA images\n", 208 | " 'to RGBA images')\n" 209 | ] 210 | }, 211 | { 212 | "name": "stdout", 213 | "output_type": "stream", 214 | "text": [ 215 | "Training complete!\n" 216 | ] 217 | } 218 | ], 219 | "source": [ 220 | "#Trainer\n", 221 | "if __name__ == \"__main__\":\n", 222 | " # STEP 1: Train the KNN classifier and save it to disk\n", 223 | " print(\"Training KNN classifier...\")\n", 224 | " classifier = train(\"known_people\",\n", 225 | " model_save_path=\"{}/models/trained_knn_model.clf\".format(curd),\n", 226 | " n_neighbors=2)\n", 227 | " print(\"Training complete!\")\n", 228 | "\n", 229 | " " 230 | ] 231 | }, 232 | { 233 | "cell_type": "code", 234 | "execution_count": 7, 235 | "metadata": {}, 236 | "outputs": [], 237 | "source": [ 238 | "#test Data Creator\n", 239 | "import cv2\n", 240 | "import numpy as np\n", 241 | "import time\n", 242 | "curd = os.getcwd()\n", 243 | "#name = input()\n", 244 | "\n", 245 | "cap = cv2.VideoCapture(0)\n", 246 | "cap.set(cv2.CAP_PROP_FPS, 100)\n", 247 | "rat, frame = cap.read()\n", 248 | "count=0\n", 249 | "while count<4:\n", 250 | " curtime = time.strftime(\"%Y_%m_%d-%H_%M_%S\")\n", 251 | " rat, frame = cap.read()\n", 252 | " cv2.imwrite(\"{}/test/{}.jpg\".format(curd,curtime), frame)\n", 253 | " count+=1\n", 254 | " cv2.imshow('img',frame)\n", 255 | " if cv2.waitKey(1) & 0xFF == ord('q'):\n", 256 | " break\n", 257 | " time.sleep(1) \n", 258 | "\n", 259 | "\n", 260 | "cap.release() \n", 261 | "cv2.destroyAllWindows()" 262 | ] 263 | }, 264 | { 265 | "cell_type": "code", 266 | "execution_count": 15, 267 | "metadata": {}, 268 | "outputs": [ 269 | { 270 | "name": "stdout", 271 | "output_type": "stream", 272 | "text": [ 273 | "Looking for faces in 0.jpg\n", 274 | "- Found Shantnu Agarwal at (253, 225)\n", 275 | "Looking for faces in 1.jpg\n", 276 | "- Found yo at (357, 276)\n", 277 | "Looking for faces in 2.jpg\n", 278 | "Looking for faces in 2019_03_31-00_37_45.jpg\n", 279 | "- Found yash at (259, 235)\n", 280 | "Looking for faces in 2019_03_31-00_37_46.jpg\n", 281 | "- Found yash at (259, 235)\n", 282 | "Looking for faces in 2019_03_31-00_37_47.jpg\n", 283 | "- Found yash at (259, 235)\n", 284 | "- Found yo at (0, 285)\n", 285 | "Looking for faces in 2019_03_31-00_37_48.jpg\n", 286 | "- Found yash at (259, 235)\n", 287 | "Looking for faces in 3.jpg\n", 288 | "Looking for faces in Dx.jpg\n", 289 | "- Found DiCap at (167, 39)\n", 290 | "Looking for faces in Jx.jpg\n", 291 | "- Found Jason at (46, 55)\n", 292 | "Looking for faces in momo.jpg\n", 293 | "- Found Jason at (8, 32)\n", 294 | "- Found unknown at (117, 122)\n", 295 | "Looking for faces in XX.jpg\n", 296 | "- Found unknown at (33, 62)\n", 297 | "- Found Jason at (89, 30)\n", 298 | "Looking for faces in Y.jpg\n", 299 | "- Found DiCap at (1526, 666)\n", 300 | "- Found unknown at (913, 82)\n", 301 | "- Found yo at (855, 626)\n", 302 | "- Found unknown at (325, 641)\n", 303 | "- Found Jason at (268, 96)\n", 304 | "- Found unknown at (1491, 133)\n" 305 | ] 306 | } 307 | ], 308 | "source": [ 309 | "#Still Image Tester\n", 310 | "curd = os.getcwd()\n", 311 | "for image_file in os.listdir(r\"{}\\test\".format(curd)):\n", 312 | " full_file_path = os.path.join(r\"{}\\test\".format(curd), image_file)\n", 313 | "\n", 314 | " print(\"Looking for faces in {}\".format(image_file))\n", 315 | " frame = cv2.imread(full_file_path,-1)\n", 316 | "\n", 317 | " predictions = predict(frame, model_path=r\"{}\\models\\trained_knn_model.clf\".format(curd))\n", 318 | "\n", 319 | " for name, (top, right, bottom, left) in predictions:\n", 320 | " print(\"- Found {} at ({}, {})\".format(name, left, top))\n", 321 | " names.append(name)\n", 322 | " # Display results overlaid on an image\n", 323 | " #show_prediction_labels_on_image(frame, predictions)\n", 324 | " final_img = show_prediction_labels_on_image(frame, predictions)\n", 325 | " cv2.imshow(\"X\",final_img)\n", 326 | " cv2.waitKey(1)\n", 327 | "cv2.destroyAllWindows()" 328 | ] 329 | }, 330 | { 331 | "cell_type": "code", 332 | "execution_count": 18, 333 | "metadata": {}, 334 | "outputs": [ 335 | { 336 | "name": "stdout", 337 | "output_type": "stream", 338 | "text": [ 339 | "- Found yash at (282, 223)\n", 340 | "- Found yash at (270, 199)\n", 341 | "- Found Shantnu Agarwal at (275, 216)\n", 342 | "- Found Shantnu Agarwal at (270, 211)\n", 343 | "- Found yash at (270, 211)\n", 344 | "- Found Shantnu Agarwal at (270, 211)\n", 345 | "- Found Shantnu Agarwal at (270, 211)\n", 346 | "- Found Shantnu Agarwal at (270, 211)\n", 347 | "- Found yash at (259, 211)\n", 348 | "- Found Shantnu Agarwal at (270, 211)\n", 349 | "- Found Shantnu Agarwal at (294, 211)\n", 350 | "- Found Shantnu Agarwal at (282, 211)\n", 351 | "- Found yash at (282, 211)\n", 352 | "- Found Shantnu Agarwal at (259, 211)\n" 353 | ] 354 | } 355 | ], 356 | "source": [ 357 | "#Live Video tester\n", 358 | "cap = cv2.VideoCapture(0)\n", 359 | "cap.set(cv2.CAP_PROP_FPS, 100)\n", 360 | "rat, frame = cap.read()\n", 361 | "\n", 362 | "while(True):\n", 363 | " rat, frame = cap.read()\n", 364 | " predictions = predict(frame, model_path=\"{}/models/trained_knn_model.clf\".format(curd))\n", 365 | " for name, (top, right, bottom, left) in predictions:\n", 366 | " print(\"- Found {} at ({}, {})\".format(name, left, top))\n", 367 | " names.append(name)\n", 368 | "\n", 369 | " # Display results overlaid on an image\n", 370 | " show_img = show_prediction_labels_on_image(frame, predictions)\n", 371 | " cv2.imshow('img',show_img)\n", 372 | " if cv2.waitKey(1) & 0xFF == ord('q'):\n", 373 | " break\n", 374 | "\n", 375 | "\n", 376 | "cap.release() \n", 377 | "cv2.destroyAllWindows()" 378 | ] 379 | }, 380 | { 381 | "cell_type": "code", 382 | "execution_count": 19, 383 | "metadata": {}, 384 | "outputs": [ 385 | { 386 | "data": { 387 | "text/html": [ 388 | "
\n", 389 | "\n", 402 | "\n", 403 | " \n", 404 | " \n", 405 | " \n", 406 | " \n", 407 | " \n", 408 | " \n", 409 | " \n", 410 | " \n", 411 | " \n", 412 | " \n", 413 | " \n", 414 | " \n", 415 | " \n", 416 | " \n", 417 | " \n", 418 | " \n", 419 | " \n", 420 | " \n", 421 | " \n", 422 | " \n", 423 | " \n", 424 | " \n", 425 | " \n", 426 | " \n", 427 | " \n", 428 | " \n", 429 | " \n", 430 | " \n", 431 | "
Present
Shantnu Agarwal1
yash1
Jason0
yo0
DiCap0
\n", 432 | "
" 433 | ], 434 | "text/plain": [ 435 | " Present\n", 436 | "Shantnu Agarwal 1\n", 437 | "yash 1\n", 438 | "Jason 0\n", 439 | "yo 0\n", 440 | "DiCap 0" 441 | ] 442 | }, 443 | "execution_count": 19, 444 | "metadata": {}, 445 | "output_type": "execute_result" 446 | } 447 | ], 448 | "source": [ 449 | "#Attendance System csv maker \n", 450 | "namesD=pd.DataFrame(names, columns=[\"Names\"])\n", 451 | "namesD= namesD[namesD.Names!=\"unknown\"]\n", 452 | "\n", 453 | "attendance= pd.DataFrame(namesD.iloc[:,0].value_counts())\n", 454 | "attendance.rename(index=str,columns={'Names': 'Count'},inplace=True)\n", 455 | "attendance[\"Present\"] =0\n", 456 | "\n", 457 | "attendance[\"Count\"][0] > 5\n", 458 | "for i in range(attendance.shape[0]):\n", 459 | " if(attendance[\"Count\"][i] > 5):\n", 460 | " attendance[\"Present\"][i] =1\n", 461 | "\n", 462 | "\n", 463 | "attendance_final=attendance.drop(['Count'],axis=1)\n", 464 | "attendance_final\n", 465 | "#attendance_final.to_csv('Attendance.csv')" 466 | ] 467 | }, 468 | { 469 | "cell_type": "code", 470 | "execution_count": null, 471 | "metadata": {}, 472 | "outputs": [], 473 | "source": [] 474 | }, 475 | { 476 | "cell_type": "code", 477 | "execution_count": null, 478 | "metadata": {}, 479 | "outputs": [], 480 | "source": [] 481 | }, 482 | { 483 | "cell_type": "code", 484 | "execution_count": null, 485 | "metadata": {}, 486 | "outputs": [], 487 | "source": [] 488 | }, 489 | { 490 | "cell_type": "code", 491 | "execution_count": null, 492 | "metadata": {}, 493 | "outputs": [], 494 | "source": [] 495 | }, 496 | { 497 | "cell_type": "code", 498 | "execution_count": null, 499 | "metadata": {}, 500 | "outputs": [], 501 | "source": [] 502 | }, 503 | { 504 | "cell_type": "code", 505 | "execution_count": null, 506 | "metadata": {}, 507 | "outputs": [], 508 | "source": [] 509 | } 510 | ], 511 | "metadata": { 512 | "kernelspec": { 513 | "display_name": "Python 3", 514 | "language": "python", 515 | "name": "python3" 516 | }, 517 | "language_info": { 518 | "codemirror_mode": { 519 | "name": "ipython", 520 | "version": 3 521 | }, 522 | "file_extension": ".py", 523 | "mimetype": "text/x-python", 524 | "name": "python", 525 | "nbconvert_exporter": "python", 526 | "pygments_lexer": "ipython3", 527 | "version": "3.6.8" 528 | } 529 | }, 530 | "nbformat": 4, 531 | "nbformat_minor": 2 532 | } 533 | -------------------------------------------------------------------------------- /face_recog/final knn model_yash_phonecam.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 2, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import math\n", 10 | "import cv2\n", 11 | "from sklearn import neighbors\n", 12 | "import numpy as np\n", 13 | "import pandas as pd\n", 14 | "import os\n", 15 | "import os.path\n", 16 | "import requests\n", 17 | "import pickle\n", 18 | "from PIL import Image, ImageDraw\n", 19 | "import face_recognition\n", 20 | "from face_recognition.face_recognition_cli import image_files_in_folder\n", 21 | "curd = os.getcwd()\n", 22 | "try: \n", 23 | " os.mkdir(\"{}/known_people\".format(curd))\n", 24 | "except:\n", 25 | " pass\n", 26 | "try: \n", 27 | " os.mkdir(\"{}/models\".format(curd))\n", 28 | "except:\n", 29 | " pass\n", 30 | "try: \n", 31 | " os.mkdir(\"{}/test\".format(curd))\n", 32 | "except:\n", 33 | " pass\n", 34 | "try: \n", 35 | " os.mkdir(\"{}/unknown_pictures\".format(curd))\n", 36 | "except:\n", 37 | " pass\n", 38 | "names=[]" 39 | ] 40 | }, 41 | { 42 | "cell_type": "code", 43 | "execution_count": 3, 44 | "metadata": {}, 45 | "outputs": [], 46 | "source": [ 47 | "ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg'}" 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": 4, 53 | "metadata": {}, 54 | "outputs": [], 55 | "source": [ 56 | "def train(train_dir, model_save_path=None, n_neighbors=None, knn_algo='ball_tree', verbose=False):\n", 57 | " \n", 58 | " X = []\n", 59 | " y = []\n", 60 | "\n", 61 | " for class_dir in os.listdir(train_dir):\n", 62 | " if not os.path.isdir(os.path.join(train_dir, class_dir)):\n", 63 | " continue\n", 64 | "\n", 65 | " for img_path in image_files_in_folder(os.path.join(train_dir, class_dir)):\n", 66 | " image = face_recognition.load_image_file(img_path)\n", 67 | " face_bounding_boxes = face_recognition.face_locations(image)\n", 68 | "\n", 69 | " if len(face_bounding_boxes) != 1:\n", 70 | " if verbose:\n", 71 | " print(\"Image {} not suitable for training: {}\".format(img_path, \"Didn't find a face\" if len(face_bounding_boxes) < 1 else \"Found more than one face\"))\n", 72 | " else:\n", 73 | " X.append(face_recognition.face_encodings(image, known_face_locations=face_bounding_boxes)[0])\n", 74 | " y.append(class_dir)\n", 75 | "\n", 76 | " if n_neighbors is None:\n", 77 | " n_neighbors = int(round(math.sqrt(len(X))))\n", 78 | " if verbose:\n", 79 | " print(\"Chose n_neighbors automatically:\", n_neighbors)\n", 80 | "\n", 81 | " knn_clf = neighbors.KNeighborsClassifier(n_neighbors=n_neighbors, algorithm=knn_algo, weights='distance')\n", 82 | " knn_clf.fit(X, y)\n", 83 | "\n", 84 | " if model_save_path is not None:\n", 85 | " with open(model_save_path, 'wb') as f:\n", 86 | " pickle.dump(knn_clf, f)\n", 87 | "\n", 88 | " return knn_clf" 89 | ] 90 | }, 91 | { 92 | "cell_type": "code", 93 | "execution_count": 5, 94 | "metadata": {}, 95 | "outputs": [], 96 | "source": [ 97 | "\n", 98 | "def predict(frame, knn_clf=None, model_path=None, distance_threshold=0.6):\n", 99 | " \n", 100 | "\n", 101 | " if knn_clf is None and model_path is None:\n", 102 | " raise Exception(\"Must supply knn classifier either thourgh knn_clf or model_path\")\n", 103 | "\n", 104 | " if knn_clf is None:\n", 105 | " with open(model_path, 'rb') as f:\n", 106 | " knn_clf = pickle.load(f)\n", 107 | "\n", 108 | " \n", 109 | " # X_img = face_recognition.load_image_file(X_img_path)\n", 110 | " X_img = frame\n", 111 | " X_face_locations = face_recognition.face_locations(X_img)\n", 112 | "\n", 113 | " if len(X_face_locations) == 0:\n", 114 | " return []\n", 115 | "\n", 116 | " faces_encodings = face_recognition.face_encodings(X_img, known_face_locations=X_face_locations)\n", 117 | "\n", 118 | " closest_distances = knn_clf.kneighbors(faces_encodings, n_neighbors=1)\n", 119 | " are_matches = [closest_distances[0][i][0] <= distance_threshold for i in range(len(X_face_locations))]\n", 120 | "\n", 121 | " return [(pred, loc) if rec else (\"unknown\", loc) for pred, loc, rec in zip(knn_clf.predict(faces_encodings), X_face_locations, are_matches)]\n" 122 | ] 123 | }, 124 | { 125 | "cell_type": "code", 126 | "execution_count": 6, 127 | "metadata": {}, 128 | "outputs": [], 129 | "source": [ 130 | "#my version\n", 131 | "def show_prediction_labels_on_image(frame, predictions):\n", 132 | " \n", 133 | " #pil_image = Image.open(img_path).convert(\"RGB\")\n", 134 | " pil_image = Image.fromarray(frame).convert(\"RGB\")\n", 135 | " draw = ImageDraw.Draw(pil_image)\n", 136 | "\n", 137 | " for name, (top, right, bottom, left) in predictions:\n", 138 | " draw.rectangle(((left, top), (right, bottom)), outline=(0, 0, 255))\n", 139 | "\n", 140 | " \n", 141 | " name = name.encode(\"UTF-8\")\n", 142 | "\n", 143 | " text_width, text_height = draw.textsize(name)\n", 144 | " draw.rectangle(((left, bottom - text_height - 10), (right, bottom)), fill=(0, 0, 255), outline=(0, 0, 255))\n", 145 | " draw.text((left + 6, bottom - text_height - 5), name, fill=(255, 255, 255, 255))\n", 146 | "\n", 147 | " del draw\n", 148 | "\n", 149 | " #pil_image.show()\n", 150 | " #cv2.imshow(\"frame\",pil_image)\n", 151 | " return np.asarray(pil_image)\n" 152 | ] 153 | }, 154 | { 155 | "cell_type": "code", 156 | "execution_count": 10, 157 | "metadata": {}, 158 | "outputs": [ 159 | { 160 | "name": "stdout", 161 | "output_type": "stream", 162 | "text": [ 163 | "shivank\n", 164 | "Creation of the directory C:\\Users\\Choudhary\\Attendance_face_recognition/known_people/shivank failed\n" 165 | ] 166 | } 167 | ], 168 | "source": [ 169 | "#Train data creator\n", 170 | "import cv2\n", 171 | "import numpy as np\n", 172 | "import time\n", 173 | "import os\n", 174 | "curd = os.getcwd()\n", 175 | "name = input()\n", 176 | "\n", 177 | "\n", 178 | "path = \"{}/known_people/{}\".format(curd,name)\n", 179 | "try: \n", 180 | " os.mkdir(path)\n", 181 | "except OSError: \n", 182 | " print (\"Creation of the directory %s failed\" % path)\n", 183 | "url = \"http://192.168.137.184:8080/shot.jpg\"\n", 184 | "count=0\n", 185 | "while count<10:\n", 186 | " img_resp = requests.get(url)\n", 187 | " img_arr = np.array(bytearray(img_resp.content),dtype = np.uint8)\n", 188 | " frame = cv2.imdecode(img_arr,-1)\n", 189 | " cv2.imwrite(\"{}/{}{}.jpg\".format(path,name,count), frame)\n", 190 | " count+=1\n", 191 | " cv2.imshow('img',frame)\n", 192 | " if cv2.waitKey(1) & 0xFF == ord('q'):\n", 193 | " break\n", 194 | " time.sleep(1) \n", 195 | "\n", 196 | "\n", 197 | " \n", 198 | "cv2.destroyAllWindows()" 199 | ] 200 | }, 201 | { 202 | "cell_type": "code", 203 | "execution_count": 11, 204 | "metadata": {}, 205 | "outputs": [ 206 | { 207 | "name": "stdout", 208 | "output_type": "stream", 209 | "text": [ 210 | "Training KNN classifier...\n" 211 | ] 212 | }, 213 | { 214 | "name": "stderr", 215 | "output_type": "stream", 216 | "text": [ 217 | "C:\\Users\\Choudhary\\Anaconda3\\envs\\mlkit\\lib\\site-packages\\PIL\\Image.py:969: UserWarning: Palette images with Transparency expressed in bytes should be converted to RGBA images\n", 218 | " 'to RGBA images')\n" 219 | ] 220 | }, 221 | { 222 | "name": "stdout", 223 | "output_type": "stream", 224 | "text": [ 225 | "Training complete!\n" 226 | ] 227 | } 228 | ], 229 | "source": [ 230 | "#Trainer\n", 231 | "if __name__ == \"__main__\":\n", 232 | " # STEP 1: Train the KNN classifier and save it to disk\n", 233 | " print(\"Training KNN classifier...\")\n", 234 | " classifier = train(\"known_people\",\n", 235 | " model_save_path=\"{}/models/trained_knn_model.clf\".format(curd),\n", 236 | " n_neighbors=2)\n", 237 | " print(\"Training complete!\")\n", 238 | "\n", 239 | " " 240 | ] 241 | }, 242 | { 243 | "cell_type": "code", 244 | "execution_count": 10, 245 | "metadata": {}, 246 | "outputs": [], 247 | "source": [ 248 | "#test Data Creator\n", 249 | "import cv2\n", 250 | "import numpy as np\n", 251 | "import time\n", 252 | "curd = os.getcwd()\n", 253 | "#name = input()\n", 254 | "url = \"http://192.168.137.184:8080/shot.jpg\"\n", 255 | "count=0\n", 256 | "while count<10:\n", 257 | " curtime = time.strftime(\"%Y_%m_%d-%H_%M_%S\")\n", 258 | " img_resp = requests.get(url)\n", 259 | " img_arr = np.array(bytearray(img_resp.content),dtype = np.uint8)\n", 260 | " frame = cv2.imdecode(img_arr,-1)\n", 261 | " cv2.imwrite(\"{}/test/{}.jpg\".format(curd,curtime), frame)\n", 262 | " count+=1\n", 263 | " cv2.imshow('img',frame)\n", 264 | " if cv2.waitKey(1) & 0xFF == ord('q'):\n", 265 | " break\n", 266 | " time.sleep(1) \n", 267 | "\n", 268 | "\n", 269 | " \n", 270 | "cv2.destroyAllWindows()" 271 | ] 272 | }, 273 | { 274 | "cell_type": "code", 275 | "execution_count": 11, 276 | "metadata": {}, 277 | "outputs": [ 278 | { 279 | "name": "stdout", 280 | "output_type": "stream", 281 | "text": [ 282 | "Looking for faces in 2019_03_31-02_04_21.jpg\n", 283 | "- Found nitin at (641, 367)\n", 284 | "- Found shivank at (378, 378)\n", 285 | "Looking for faces in 2019_03_31-02_04_22.jpg\n", 286 | "- Found nitin at (626, 368)\n", 287 | "- Found shivank at (366, 378)\n", 288 | "Looking for faces in 2019_03_31-02_04_24.jpg\n", 289 | "- Found shivank at (378, 390)\n", 290 | "Looking for faces in 2019_03_31-02_04_25.jpg\n", 291 | "- Found nitin at (617, 390)\n", 292 | "Looking for faces in 2019_03_31-02_04_26.jpg\n", 293 | "- Found unknown at (581, 355)\n", 294 | "Looking for faces in 2019_03_31-02_04_28.jpg\n", 295 | "- Found shivank at (318, 259)\n", 296 | "- Found yo at (964, 366)\n", 297 | "- Found nitin at (545, 283)\n", 298 | "- Found yo at (165, 258)\n", 299 | "Looking for faces in 2019_03_31-02_04_29.jpg\n", 300 | "- Found shivank at (318, 295)\n", 301 | "- Found shant at (199, 285)\n", 302 | "- Found nitin at (569, 325)\n", 303 | "Looking for faces in 2019_03_31-02_04_31.jpg\n", 304 | "- Found yo at (569, 367)\n", 305 | "- Found shivank at (294, 331)\n", 306 | "Looking for faces in 2019_03_31-02_04_32.jpg\n", 307 | "- Found shivank at (294, 343)\n", 308 | "- Found nitin at (540, 354)\n", 309 | "- Found yash at (985, 428)\n", 310 | "Looking for faces in 2019_03_31-02_04_34.jpg\n", 311 | "- Found nitin at (593, 378)\n", 312 | "- Found shivank at (285, 365)\n", 313 | "Looking for faces in Dx.jpg\n", 314 | "- Found DiCap at (167, 39)\n", 315 | "Looking for faces in Jx.jpg\n", 316 | "- Found Jason at (46, 55)\n", 317 | "Looking for faces in momo.jpg\n", 318 | "- Found Jason at (8, 32)\n", 319 | "- Found unknown at (117, 122)\n", 320 | "Looking for faces in XX.jpg\n", 321 | "- Found unknown at (33, 62)\n", 322 | "- Found Jason at (89, 30)\n", 323 | "Looking for faces in Y.jpg\n", 324 | "- Found DiCap at (1526, 666)\n", 325 | "- Found unknown at (913, 82)\n", 326 | "- Found yo at (855, 626)\n", 327 | "- Found unknown at (325, 641)\n", 328 | "- Found Jason at (268, 96)\n", 329 | "- Found unknown at (1491, 133)\n" 330 | ] 331 | } 332 | ], 333 | "source": [ 334 | "#Still Image Tester\n", 335 | "curd = os.getcwd()\n", 336 | "for image_file in os.listdir(r\"{}\\test\".format(curd)):\n", 337 | " full_file_path = os.path.join(r\"{}\\test\".format(curd), image_file)\n", 338 | "\n", 339 | " print(\"Looking for faces in {}\".format(image_file))\n", 340 | " frame = cv2.imread(full_file_path,-1)\n", 341 | "\n", 342 | " predictions = predict(frame, model_path=r\"{}\\models\\trained_knn_model.clf\".format(curd))\n", 343 | "\n", 344 | " for name, (top, right, bottom, left) in predictions:\n", 345 | " print(\"- Found {} at ({}, {})\".format(name, left, top))\n", 346 | " names.append(name)\n", 347 | " # Display results overlaid on an image\n", 348 | " #show_prediction_labels_on_image(frame, predictions)\n", 349 | " final_img = show_prediction_labels_on_image(frame, predictions)\n", 350 | " cv2.imshow(\"X\",final_img)\n", 351 | " cv2.waitKey(100)\n", 352 | "cv2.destroyAllWindows()" 353 | ] 354 | }, 355 | { 356 | "cell_type": "code", 357 | "execution_count": 14, 358 | "metadata": {}, 359 | "outputs": [ 360 | { 361 | "name": "stdout", 362 | "output_type": "stream", 363 | "text": [ 364 | "- Found shivank at (196, 53)\n", 365 | "- Found shivank at (325, 39)\n", 366 | "- Found shivank at (325, 53)\n", 367 | "- Found shivank at (296, 110)\n", 368 | "- Found nitin at (411, 239)\n", 369 | "- Found shivank at (259, 104)\n", 370 | "- Found shivank at (259, 104)\n", 371 | "- Found nitin at (497, 153)\n", 372 | "- Found shivank at (259, 116)\n", 373 | "- Found nitin at (497, 153)\n", 374 | "- Found shivank at (259, 104)\n", 375 | "- Found nitin at (497, 153)\n", 376 | "- Found shivank at (259, 104)\n", 377 | "- Found nitin at (497, 153)\n", 378 | "- Found shivank at (253, 82)\n", 379 | "- Found nitin at (497, 125)\n", 380 | "- Found shivank at (270, 80)\n", 381 | "- Found nitin at (511, 125)\n" 382 | ] 383 | }, 384 | { 385 | "ename": "ConnectionError", 386 | "evalue": "HTTPConnectionPool(host='192.168.137.184', port=8080): Max retries exceeded with url: /shot.jpg (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',))", 387 | "output_type": "error", 388 | "traceback": [ 389 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 390 | "\u001b[1;31mConnectionRefusedError\u001b[0m Traceback (most recent call last)", 391 | "\u001b[1;32m~\\Anaconda3\\envs\\mlkit\\lib\\site-packages\\urllib3\\connection.py\u001b[0m in \u001b[0;36m_new_conn\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 158\u001b[0m conn = connection.create_connection(\n\u001b[1;32m--> 159\u001b[1;33m (self._dns_host, self.port), self.timeout, **extra_kw)\n\u001b[0m\u001b[0;32m 160\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", 392 | "\u001b[1;32m~\\Anaconda3\\envs\\mlkit\\lib\\site-packages\\urllib3\\util\\connection.py\u001b[0m in \u001b[0;36mcreate_connection\u001b[1;34m(address, timeout, source_address, socket_options)\u001b[0m\n\u001b[0;32m 79\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0merr\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 80\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 81\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", 393 | "\u001b[1;32m~\\Anaconda3\\envs\\mlkit\\lib\\site-packages\\urllib3\\util\\connection.py\u001b[0m in \u001b[0;36mcreate_connection\u001b[1;34m(address, timeout, source_address, socket_options)\u001b[0m\n\u001b[0;32m 69\u001b[0m \u001b[0msock\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mbind\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msource_address\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 70\u001b[1;33m \u001b[0msock\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mconnect\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msa\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 71\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0msock\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", 394 | "\u001b[1;31mConnectionRefusedError\u001b[0m: [WinError 10061] No connection could be made because the target machine actively refused it", 395 | "\nDuring handling of the above exception, another exception occurred:\n", 396 | "\u001b[1;31mNewConnectionError\u001b[0m Traceback (most recent call last)", 397 | "\u001b[1;32m~\\Anaconda3\\envs\\mlkit\\lib\\site-packages\\urllib3\\connectionpool.py\u001b[0m in \u001b[0;36murlopen\u001b[1;34m(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)\u001b[0m\n\u001b[0;32m 599\u001b[0m \u001b[0mbody\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mbody\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mheaders\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mheaders\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 600\u001b[1;33m chunked=chunked)\n\u001b[0m\u001b[0;32m 601\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", 398 | "\u001b[1;32m~\\Anaconda3\\envs\\mlkit\\lib\\site-packages\\urllib3\\connectionpool.py\u001b[0m in \u001b[0;36m_make_request\u001b[1;34m(self, conn, method, url, timeout, chunked, **httplib_request_kw)\u001b[0m\n\u001b[0;32m 353\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 354\u001b[1;33m \u001b[0mconn\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrequest\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmethod\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0murl\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mhttplib_request_kw\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 355\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", 399 | "\u001b[1;32m~\\Anaconda3\\envs\\mlkit\\lib\\http\\client.py\u001b[0m in \u001b[0;36mrequest\u001b[1;34m(self, method, url, body, headers, encode_chunked)\u001b[0m\n\u001b[0;32m 1238\u001b[0m \u001b[1;34m\"\"\"Send a complete request to the server.\"\"\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1239\u001b[1;33m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_send_request\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmethod\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0murl\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mbody\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mheaders\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mencode_chunked\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1240\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", 400 | "\u001b[1;32m~\\Anaconda3\\envs\\mlkit\\lib\\http\\client.py\u001b[0m in \u001b[0;36m_send_request\u001b[1;34m(self, method, url, body, headers, encode_chunked)\u001b[0m\n\u001b[0;32m 1284\u001b[0m \u001b[0mbody\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0m_encode\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mbody\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'body'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1285\u001b[1;33m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mendheaders\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mbody\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mencode_chunked\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mencode_chunked\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1286\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", 401 | "\u001b[1;32m~\\Anaconda3\\envs\\mlkit\\lib\\http\\client.py\u001b[0m in \u001b[0;36mendheaders\u001b[1;34m(self, message_body, encode_chunked)\u001b[0m\n\u001b[0;32m 1233\u001b[0m \u001b[1;32mraise\u001b[0m \u001b[0mCannotSendHeader\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1234\u001b[1;33m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_send_output\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmessage_body\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mencode_chunked\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mencode_chunked\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1235\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", 402 | "\u001b[1;32m~\\Anaconda3\\envs\\mlkit\\lib\\http\\client.py\u001b[0m in \u001b[0;36m_send_output\u001b[1;34m(self, message_body, encode_chunked)\u001b[0m\n\u001b[0;32m 1025\u001b[0m \u001b[1;32mdel\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_buffer\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1026\u001b[1;33m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmsg\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1027\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", 403 | "\u001b[1;32m~\\Anaconda3\\envs\\mlkit\\lib\\http\\client.py\u001b[0m in \u001b[0;36msend\u001b[1;34m(self, data)\u001b[0m\n\u001b[0;32m 963\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mauto_open\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 964\u001b[1;33m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mconnect\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 965\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", 404 | "\u001b[1;32m~\\Anaconda3\\envs\\mlkit\\lib\\site-packages\\urllib3\\connection.py\u001b[0m in \u001b[0;36mconnect\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 180\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mconnect\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 181\u001b[1;33m \u001b[0mconn\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_new_conn\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 182\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_prepare_conn\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mconn\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", 405 | "\u001b[1;32m~\\Anaconda3\\envs\\mlkit\\lib\\site-packages\\urllib3\\connection.py\u001b[0m in \u001b[0;36m_new_conn\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 167\u001b[0m raise NewConnectionError(\n\u001b[1;32m--> 168\u001b[1;33m self, \"Failed to establish a new connection: %s\" % e)\n\u001b[0m\u001b[0;32m 169\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", 406 | "\u001b[1;31mNewConnectionError\u001b[0m: : Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it", 407 | "\nDuring handling of the above exception, another exception occurred:\n", 408 | "\u001b[1;31mMaxRetryError\u001b[0m Traceback (most recent call last)", 409 | "\u001b[1;32m~\\Anaconda3\\envs\\mlkit\\lib\\site-packages\\requests\\adapters.py\u001b[0m in \u001b[0;36msend\u001b[1;34m(self, request, stream, timeout, verify, cert, proxies)\u001b[0m\n\u001b[0;32m 448\u001b[0m \u001b[0mretries\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmax_retries\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 449\u001b[1;33m \u001b[0mtimeout\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mtimeout\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 450\u001b[0m )\n", 410 | "\u001b[1;32m~\\Anaconda3\\envs\\mlkit\\lib\\site-packages\\urllib3\\connectionpool.py\u001b[0m in \u001b[0;36murlopen\u001b[1;34m(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)\u001b[0m\n\u001b[0;32m 637\u001b[0m retries = retries.increment(method, url, error=e, _pool=self,\n\u001b[1;32m--> 638\u001b[1;33m _stacktrace=sys.exc_info()[2])\n\u001b[0m\u001b[0;32m 639\u001b[0m \u001b[0mretries\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msleep\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", 411 | "\u001b[1;32m~\\Anaconda3\\envs\\mlkit\\lib\\site-packages\\urllib3\\util\\retry.py\u001b[0m in \u001b[0;36mincrement\u001b[1;34m(self, method, url, response, error, _pool, _stacktrace)\u001b[0m\n\u001b[0;32m 397\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mnew_retry\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mis_exhausted\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 398\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mMaxRetryError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0m_pool\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0murl\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0merror\u001b[0m \u001b[1;32mor\u001b[0m \u001b[0mResponseError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcause\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 399\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", 412 | "\u001b[1;31mMaxRetryError\u001b[0m: HTTPConnectionPool(host='192.168.137.184', port=8080): Max retries exceeded with url: /shot.jpg (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',))", 413 | "\nDuring handling of the above exception, another exception occurred:\n", 414 | "\u001b[1;31mConnectionError\u001b[0m Traceback (most recent call last)", 415 | "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[1;32mwhile\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;32mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 5\u001b[1;33m \u001b[0mimg_resp\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mrequests\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0murl\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 6\u001b[0m \u001b[0mimg_arr\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0marray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mbytearray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mimg_resp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcontent\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mdtype\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0muint8\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 7\u001b[0m \u001b[0mframe\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mcv2\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mimdecode\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mimg_arr\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", 416 | "\u001b[1;32m~\\Anaconda3\\envs\\mlkit\\lib\\site-packages\\requests\\api.py\u001b[0m in \u001b[0;36mget\u001b[1;34m(url, params, **kwargs)\u001b[0m\n\u001b[0;32m 73\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 74\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msetdefault\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'allow_redirects'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 75\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mrequest\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'get'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0murl\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mparams\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mparams\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 76\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 77\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", 417 | "\u001b[1;32m~\\Anaconda3\\envs\\mlkit\\lib\\site-packages\\requests\\api.py\u001b[0m in \u001b[0;36mrequest\u001b[1;34m(method, url, **kwargs)\u001b[0m\n\u001b[0;32m 58\u001b[0m \u001b[1;31m# cases, and look like a memory leak in others.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 59\u001b[0m \u001b[1;32mwith\u001b[0m \u001b[0msessions\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mSession\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0msession\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 60\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0msession\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrequest\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmethod\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mmethod\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0murl\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0murl\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 61\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 62\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", 418 | "\u001b[1;32m~\\Anaconda3\\envs\\mlkit\\lib\\site-packages\\requests\\sessions.py\u001b[0m in \u001b[0;36mrequest\u001b[1;34m(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)\u001b[0m\n\u001b[0;32m 531\u001b[0m }\n\u001b[0;32m 532\u001b[0m \u001b[0msend_kwargs\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mupdate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msettings\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 533\u001b[1;33m \u001b[0mresp\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mprep\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0msend_kwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 534\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 535\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mresp\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", 419 | "\u001b[1;32m~\\Anaconda3\\envs\\mlkit\\lib\\site-packages\\requests\\sessions.py\u001b[0m in \u001b[0;36msend\u001b[1;34m(self, request, **kwargs)\u001b[0m\n\u001b[0;32m 644\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 645\u001b[0m \u001b[1;31m# Send the request\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 646\u001b[1;33m \u001b[0mr\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0madapter\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mrequest\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 647\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 648\u001b[0m \u001b[1;31m# Total elapsed time of the request (approximately)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", 420 | "\u001b[1;32m~\\Anaconda3\\envs\\mlkit\\lib\\site-packages\\requests\\adapters.py\u001b[0m in \u001b[0;36msend\u001b[1;34m(self, request, stream, timeout, verify, cert, proxies)\u001b[0m\n\u001b[0;32m 514\u001b[0m \u001b[1;32mraise\u001b[0m \u001b[0mSSLError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0me\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mrequest\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mrequest\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 515\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 516\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mConnectionError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0me\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mrequest\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mrequest\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 517\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 518\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mClosedPoolError\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", 421 | "\u001b[1;31mConnectionError\u001b[0m: HTTPConnectionPool(host='192.168.137.184', port=8080): Max retries exceeded with url: /shot.jpg (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',))" 422 | ] 423 | } 424 | ], 425 | "source": [ 426 | "#Live Video tester\n", 427 | "url = \"http://192.168.137.184:8080/shot.jpg\"\n", 428 | "\n", 429 | "while(True):\n", 430 | " img_resp = requests.get(url)\n", 431 | " img_arr = np.array(bytearray(img_resp.content),dtype = np.uint8)\n", 432 | " frame = cv2.imdecode(img_arr,-1)\n", 433 | " predictions = predict(frame, model_path=\"{}/models/trained_knn_model.clf\".format(curd))\n", 434 | " for name, (top, right, bottom, left) in predictions:\n", 435 | " print(\"- Found {} at ({}, {})\".format(name, left, top))\n", 436 | " names.append(name)\n", 437 | "\n", 438 | " # Display results overlaid on an image\n", 439 | " show_img = show_prediction_labels_on_image(frame, predictions)\n", 440 | " cv2.imshow('img',show_img)\n", 441 | " if cv2.waitKey(1) & 0xFF == ord('q'):\n", 442 | " break\n", 443 | "\n", 444 | "\n", 445 | " \n", 446 | "cv2.destroyAllWindows()" 447 | ] 448 | }, 449 | { 450 | "cell_type": "code", 451 | "execution_count": 13, 452 | "metadata": {}, 453 | "outputs": [ 454 | { 455 | "name": "stdout", 456 | "output_type": "stream", 457 | "text": [ 458 | "- Found yo at (137, 213)\n", 459 | "- Found nitin at (137, 213)\n", 460 | "- Found shant at (448, 233)\n", 461 | "- Found yash at (494, 202)\n", 462 | "- Found yo at (443, 233)\n", 463 | "- Found yash at (494, 184)\n", 464 | "- Found yash at (494, 202)\n", 465 | "- Found yash at (511, 196)\n", 466 | "- Found yo at (46, 216)\n", 467 | "- Found yash at (354, 182)\n" 468 | ] 469 | } 470 | ], 471 | "source": [ 472 | "#Live Video tester\n", 473 | "cap = cv2.VideoCapture(0)\n", 474 | "cap.set(cv2.CAP_PROP_FPS, 100)\n", 475 | "rat, frame = cap.read()\n", 476 | "\n", 477 | "while(True):\n", 478 | " rat, frame = cap.read()\n", 479 | " predictions = predict(frame, model_path=\"{}/models/trained_knn_model.clf\".format(curd))\n", 480 | " for name, (top, right, bottom, left) in predictions:\n", 481 | " print(\"- Found {} at ({}, {})\".format(name, left, top))\n", 482 | " names.append(name)\n", 483 | "\n", 484 | " # Display results overlaid on an image\n", 485 | " show_img = show_prediction_labels_on_image(frame, predictions)\n", 486 | " cv2.imshow('img',show_img)\n", 487 | " if cv2.waitKey(1) & 0xFF == ord('q'):\n", 488 | " break\n", 489 | "\n", 490 | "\n", 491 | "cap.release() \n", 492 | "cv2.destroyAllWindows()" 493 | ] 494 | }, 495 | { 496 | "cell_type": "code", 497 | "execution_count": 19, 498 | "metadata": {}, 499 | "outputs": [ 500 | { 501 | "data": { 502 | "text/html": [ 503 | "
\n", 504 | "\n", 517 | "\n", 518 | " \n", 519 | " \n", 520 | " \n", 521 | " \n", 522 | " \n", 523 | " \n", 524 | " \n", 525 | " \n", 526 | " \n", 527 | " \n", 528 | " \n", 529 | " \n", 530 | " \n", 531 | " \n", 532 | " \n", 533 | " \n", 534 | " \n", 535 | " \n", 536 | " \n", 537 | " \n", 538 | " \n", 539 | " \n", 540 | " \n", 541 | " \n", 542 | " \n", 543 | " \n", 544 | " \n", 545 | " \n", 546 | "
Present
Shantnu Agarwal1
yash1
Jason0
yo0
DiCap0
\n", 547 | "
" 548 | ], 549 | "text/plain": [ 550 | " Present\n", 551 | "Shantnu Agarwal 1\n", 552 | "yash 1\n", 553 | "Jason 0\n", 554 | "yo 0\n", 555 | "DiCap 0" 556 | ] 557 | }, 558 | "execution_count": 19, 559 | "metadata": {}, 560 | "output_type": "execute_result" 561 | } 562 | ], 563 | "source": [ 564 | "#Attendance System csv maker \n", 565 | "namesD=pd.DataFrame(names, columns=[\"Names\"])\n", 566 | "namesD= namesD[namesD.Names!=\"unknown\"]\n", 567 | "\n", 568 | "attendance= pd.DataFrame(namesD.iloc[:,0].value_counts())\n", 569 | "attendance.rename(index=str,columns={'Names': 'Count'},inplace=True)\n", 570 | "attendance[\"Present\"] =0\n", 571 | "\n", 572 | "attendance[\"Count\"][0] > 5\n", 573 | "for i in range(attendance.shape[0]):\n", 574 | " if(attendance[\"Count\"][i] > 5):\n", 575 | " attendance[\"Present\"][i] =1\n", 576 | "\n", 577 | "\n", 578 | "attendance_final=attendance.drop(['Count'],axis=1)\n", 579 | "attendance_final\n", 580 | "#attendance_final.to_csv('Attendance.csv')" 581 | ] 582 | }, 583 | { 584 | "cell_type": "code", 585 | "execution_count": null, 586 | "metadata": {}, 587 | "outputs": [], 588 | "source": [] 589 | }, 590 | { 591 | "cell_type": "code", 592 | "execution_count": null, 593 | "metadata": {}, 594 | "outputs": [], 595 | "source": [] 596 | }, 597 | { 598 | "cell_type": "code", 599 | "execution_count": null, 600 | "metadata": {}, 601 | "outputs": [], 602 | "source": [] 603 | }, 604 | { 605 | "cell_type": "code", 606 | "execution_count": null, 607 | "metadata": {}, 608 | "outputs": [], 609 | "source": [] 610 | }, 611 | { 612 | "cell_type": "code", 613 | "execution_count": null, 614 | "metadata": {}, 615 | "outputs": [], 616 | "source": [] 617 | }, 618 | { 619 | "cell_type": "code", 620 | "execution_count": null, 621 | "metadata": {}, 622 | "outputs": [], 623 | "source": [] 624 | } 625 | ], 626 | "metadata": { 627 | "kernelspec": { 628 | "display_name": "Python 3", 629 | "language": "python", 630 | "name": "python3" 631 | }, 632 | "language_info": { 633 | "codemirror_mode": { 634 | "name": "ipython", 635 | "version": 3 636 | }, 637 | "file_extension": ".py", 638 | "mimetype": "text/x-python", 639 | "name": "python", 640 | "nbconvert_exporter": "python", 641 | "pygments_lexer": "ipython3", 642 | "version": "3.6.8" 643 | } 644 | }, 645 | "nbformat": 4, 646 | "nbformat_minor": 2 647 | } 648 | -------------------------------------------------------------------------------- /face_recog/known_people/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NitinDatta8/Automatic-Attendance-System-Using-Face-Recognition/1e5b2597a9821cecea08b173b71132d562ba900c/face_recog/known_people/test.jpg -------------------------------------------------------------------------------- /face_recog/models/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NitinDatta8/Automatic-Attendance-System-Using-Face-Recognition/1e5b2597a9821cecea08b173b71132d562ba900c/face_recog/models/test.jpg -------------------------------------------------------------------------------- /face_recog/test/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NitinDatta8/Automatic-Attendance-System-Using-Face-Recognition/1e5b2597a9821cecea08b173b71132d562ba900c/face_recog/test/test.jpg -------------------------------------------------------------------------------- /face_recog/unknown_pictures/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NitinDatta8/Automatic-Attendance-System-Using-Face-Recognition/1e5b2597a9821cecea08b173b71132d562ba900c/face_recog/unknown_pictures/test.jpg -------------------------------------------------------------------------------- /main/Attendance.csv: -------------------------------------------------------------------------------- 1 | ,Present 2 | RA1711003010488,1 3 | -------------------------------------------------------------------------------- /main/adminLogin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Gully Boys - Attendance System 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 19 |
20 | Go back 21 |
22 | 23 |
24 |
25 |

Welcome Admin, please login below to proceed.

26 |
27 |
28 |
29 |
30 | 31 | 32 |
33 |
34 |
35 |
36 | 37 | 38 |
39 |
40 |
41 | Submit and Login 42 | 43 | 44 | 45 | 46 | 47 |
48 | 49 | 50 | 51 | 52 | 53 | 54 |
55 |
56 |
57 |
58 |
Automatic Attendance System
59 |

Mozofest 2019 Hackathon, 30th-31st March, 2019

60 |
61 |
62 |
63 | Exit Panel 64 |
65 |
66 |
67 | 72 |
73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 96 | 97 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /main/adminScreen.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Gully Boys - Attendance System 6 | 7 | 8 | 9 | 10 | 11 | 22 | 23 | 24 | 25 | 30 | 31 | 32 |
33 | Log Out 34 |
35 | 36 | 37 |
38 | 39 |

Welcome, Administrator.

40 | 41 |



42 |

Choose the day order for which you want to see the student statistics.

43 |
44 | 49 | 50 |
51 |



52 | 53 | 54 |
55 | 58 | 59 |
60 |
61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 |
74 |
75 |
76 |
77 |
Automatic Attendance System
78 |

Mozofest 2019 Hackathon, 30th-31st March, 2019

79 |
80 |
81 |
82 | Exit Panel 83 |
84 |
85 |
86 | 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 | 118 | 119 | 124 | -------------------------------------------------------------------------------- /main/assets/models/trained_knn_model.clf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NitinDatta8/Automatic-Attendance-System-Using-Face-Recognition/1e5b2597a9821cecea08b173b71132d562ba900c/main/assets/models/trained_knn_model.clf -------------------------------------------------------------------------------- /main/dataEntry.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Gully Boys - Attendance System 6 | 7 | 8 | 9 | 10 | 11 | 12 | 26 | 27 | 28 | 29 | 30 | 31 | 36 |
37 |
38 |
39 | 40 | 41 | 42 |
43 | Log Out 44 |
45 | 46 |
47 |
48 |

Dear Staff member, all field shown here are mandatory. Please fill with caution and only click the train button 49 | when all students have given their details. 50 |

51 |
52 |
53 |
54 |
55 |
56 | 57 | 58 |
59 |
60 |
61 |
62 | 63 | 64 |
65 |
66 | Submit details 67 | Begin Training 68 |
69 | 70 | 71 | 73 | 74 |
75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 |
87 | 88 | 91 |


92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 |
104 |
105 |
106 |
107 |
Automatic Attendance System
108 |

Mozofest 2019 Hackathon, 30th-31st March, 2019

109 |
110 |
111 |
112 | Exit Panel 113 |
114 |
115 |
116 | 119 |
120 |
121 |
122 | 127 |
128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 154 | 159 | 160 | -------------------------------------------------------------------------------- /main/etc/data1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Gully Boys - Attendance System 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 19 | 20 |
21 | Go back 22 |
23 | 24 | 25 |
26 |

Attendance Statistics for

27 |
Day Order: 1
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 |
Registration NumberStudent NamePresent(1)/Absent(0)
RA1711003010251Yash1
RA1711003010350Shantnu1
RA1711003010488Shivank0
RA1711003010512Nitin1
RA1611003060265Alvin0
RA171100301000Kesari0
RA1711003010411Mukesh1
75 |
76 |
77 |
78 | Previous Day Order 79 |
80 |
81 | Next Day Order 82 |
83 |
84 | 85 |
86 | 87 |





88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 |
99 |
100 |
101 |
102 |
Automatic Attendance System
103 |

Mozofest 2019 Hackathon, 30th-31st March, 2019

104 |
105 |
106 |
107 | Exit Panel 108 |
109 |
110 |
111 | 116 |
117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 139 | 140 | 145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /main/etc/data2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Gully Boys - Attendance System 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 19 | 20 |
21 | Go back 22 |
23 | 24 | 25 |
26 |

Attendance Statistics for

27 |
Day Order: 2
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 |
Registration NumberStudent NamePresent(1)/Absent(0)
RA1711003010369Anany1
RA1711003010992Yash0
RA1711003010859Movva1
RA1611003060265Shivank0
RA1711003010512Nitin1
RA1711003010350Shantnu1
RA1711003010411Anil0
75 |
76 |
77 |
78 | Previous Day Order 79 |
80 |
81 | Next Day Order 82 |
83 |
84 | 85 |





86 | 87 | 88 | 89 |
90 | 91 | 92 | 93 | 94 | 95 | 96 |
97 |
98 |
99 |
100 |
Automatic Attendance System
101 |

Mozofest 2019 Hackathon, 30th-31st March, 2019

102 |
103 |
104 |
105 | Exit Panel 106 |
107 |
108 |
109 | 114 |
115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 137 | 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /main/etc/data3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Gully Boys - Attendance System 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 19 | 20 |
21 | Go back 22 |
23 | 24 | 25 |
26 |

Attendance Statistics for

27 |
Day Order: 3
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 |
Registration NumberStudent NamePresent(1)/Absent(0)
RA1711003010350Elon Musk0
RA1711003010369Shantnu1
RA1711003010411Nitin1
RA1711003010369Yash0
RA1711003010992Shivank1
RA171100301000Rahul0
RA1611003060265Vivek1
76 |
77 |
78 |
79 | Previous Day Order 80 |
81 |
82 | Next Day Order 83 |
84 |
85 | 86 |





87 | 88 | 89 | 90 |
91 | 92 | 93 | 94 | 95 | 96 | 97 |
98 |
99 |
100 |
101 |
Automatic Attendance System
102 |

Mozofest 2019 Hackathon, 30th-31st March, 2019

103 |
104 |
105 |
106 | Exit Panel 107 |
108 |
109 |
110 | 115 |
116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 137 | 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /main/facultyLogin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Gully Boys - Attendance System 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 19 |
20 | Go back 21 |
22 | 23 |
24 |
25 |

Dear staff member, please login below to proceed with the student registration process.

26 |
27 |
28 |
29 |
30 | 31 | 32 |
33 |
34 |
35 |
36 | 37 | 38 |
39 |
40 |
41 | Submit and Login 42 | 43 | 44 | 45 | 46 | 47 |
48 | 49 | 50 | 51 | 52 | 53 | 54 |
55 |
56 |
57 |
58 |
Automatic Attendance System
59 |

Mozofest 2019 Hackathon, 30th-31st March, 2019

60 |
61 |
62 |
63 | Exit Panel 64 |
65 |
66 |
67 | 72 |
73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 97 | 98 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /main/img/dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NitinDatta8/Automatic-Attendance-System-Using-Face-Recognition/1e5b2597a9821cecea08b173b71132d562ba900c/main/img/dp.png -------------------------------------------------------------------------------- /main/img/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NitinDatta8/Automatic-Attendance-System-Using-Face-Recognition/1e5b2597a9821cecea08b173b71132d562ba900c/main/img/icon.png -------------------------------------------------------------------------------- /main/img/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NitinDatta8/Automatic-Attendance-System-Using-Face-Recognition/1e5b2597a9821cecea08b173b71132d562ba900c/main/img/user.png -------------------------------------------------------------------------------- /main/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Gully Boys - Attendance System 6 | 7 | 8 | 9 | 10 | 11 | 22 | 23 | 24 | 25 | 30 | 31 |
32 | 33 |

Automated Attendance Control Panel

34 | 35 |



36 |

Please choose an option to proceed

37 |



38 |
39 |
40 | Enroll New Student 41 |
42 |
43 |
44 | 47 |
48 | 49 |
50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
64 |
65 |
66 |
67 |
Automatic Attendance System
68 |

Mozofest 2019 Hackathon, 30th-31st March, 2019

69 |
70 |
71 |
72 | Exit Panel 73 |
74 |
75 |
76 | 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 | 108 | 113 | 114 | -------------------------------------------------------------------------------- /main/js/adminLogin.js: -------------------------------------------------------------------------------- 1 | // Initialize Firebase 2 | var config = { 3 | apiKey: "AIzaSyAlkTeBTBPtnVAaOnNmwiwsFVDIWKhfp5M", 4 | authDomain: "hackathon-mozofest-2019.firebaseapp.com", 5 | databaseURL: "https://hackathon-mozofest-2019.firebaseio.com", 6 | projectId: "hackathon-mozofest-2019", 7 | storageBucket: "hackathon-mozofest-2019.appspot.com", 8 | messagingSenderId: "835193922935" 9 | }; 10 | firebase.initializeApp(config); 11 | //Clear any signed in users...... 12 | firebase.auth().signOut().then(function() { 13 | console.log("Sign out successful"); 14 | }).catch(function(error) { 15 | console.log("Error singing out"); 16 | }); 17 | 18 | 19 | function foo(){ 20 | var email = document.getElementById("loginemail").value; 21 | var password = document.getElementById("loginpassword").value; 22 | 23 | firebase.auth().signInWithEmailAndPassword(email,password).catch(function(error) { //catch errors if any 24 | console.log(error); 25 | }).then(function(){ //when login is complete, only then..... 26 | var user = firebase.auth().currentUser; 27 | if(user!=null){ 28 | console.log("Admin Login Success"); 29 | document.location.href = "adminScreen.html"; 30 | } 31 | else{ 32 | console.log("Login Unsuccessful"); 33 | M.toast({html: 'Invalid credentials! Please try again!'}); 34 | } 35 | }); 36 | // console.log("outside"); 37 | 38 | } -------------------------------------------------------------------------------- /main/js/adminScreen.js: -------------------------------------------------------------------------------- 1 | var options = {}; 2 | var elems = {}; 3 | var fs = require('fs') 4 | var config = { 5 | apiKey: "AIzaSyAlkTeBTBPtnVAaOnNmwiwsFVDIWKhfp5M", 6 | authDomain: "hackathon-mozofest-2019.firebaseapp.com", 7 | databaseURL: "https://hackathon-mozofest-2019.firebaseio.com", 8 | storageBucket: 'gs://hackathon-mozofest-2019.appspot.com/' 9 | }; 10 | 11 | firebase.initializeApp(config); 12 | var user = firebase.auth().currentUser; 13 | 14 | firebase.auth().onAuthStateChanged(function(user) { 15 | if (user) { 16 | console.log("Loggd in already : " + user.email); 17 | M.toast({html:'Welcome back ' + user.email + ' !'}); 18 | } 19 | }); 20 | 21 | 22 | 23 | 24 | document.addEventListener('DOMContentLoaded', function() { 25 | elems = document.querySelectorAll('select'); 26 | var instances = M.FormSelect.init(elems, options); 27 | }); 28 | 29 | 30 | $('select').on('change', function() { 31 | // console.log($(this).val()); 32 | foo($(this).val()); 33 | }); 34 | var selection; 35 | function foo(selection){ 36 | console.log(selection + " from inside foo along with user : " + user); 37 | switch(selection){ 38 | case '1': document.location.href = "etc/data1.html"; 39 | break; 40 | case '2': document.location.href = "etc/data2.html"; 41 | break; 42 | case '3': document.location.href = "etc/data3.html"; 43 | break; 44 | } 45 | 46 | //fetch from database 47 | // Admin signed in. 48 | 49 | } 50 | 51 | function logOut(){ 52 | console.log("Attempting Sign Out"); 53 | firebase.auth().signOut().then(function() { 54 | console.log("Sign out successful"); 55 | document.location.href = "adminLogin.html"; 56 | }).catch(function(error) { 57 | console.log("Error singing out"); 58 | }); 59 | } 60 | function pyCam(){ 61 | 62 | console.log("Camera Input Running"); 63 | M.toast({html:'Opening Camera Feed'}); 64 | var python = require('child_process').spawn('python', ['py/camcap2.py']); 65 | python.stdout.on('data',function(data){ 66 | console.log("data: ",data.toString('utf8')+ " from Python "); 67 | 68 | sendCSV(); 69 | }); 70 | 71 | } 72 | function sendCSV(){ 73 | 74 | 75 | } 76 | 77 | console.log("JS ready"); -------------------------------------------------------------------------------- /main/js/data1.js: -------------------------------------------------------------------------------- 1 | var config = { 2 | apiKey: "AIzaSyAlkTeBTBPtnVAaOnNmwiwsFVDIWKhfp5M", 3 | authDomain: "hackathon-mozofest-2019.firebaseapp.com", 4 | databaseURL: "https://hackathon-mozofest-2019.firebaseio.com", 5 | storageBucket: 'gs://hackathon-mozofest-2019.appspot.com/' 6 | }; 7 | 8 | firebase.initializeApp(config); 9 | var user = firebase.auth().currentUser; 10 | 11 | 12 | var database = firebase.database(); 13 | 14 | 15 | var starCountRef = firebase.database().ref('Students'); 16 | starCountRef.on('value', function(snapshot) { 17 | var response = snapshot.val(); 18 | console.log(response); 19 | document.getElementById(elem1).innerHTML=response.RA1711003010350.RegNo; 20 | } 21 | ); -------------------------------------------------------------------------------- /main/js/facultyLogin.js: -------------------------------------------------------------------------------- 1 | // Initialize Firebase 2 | 3 | var config = { 4 | apiKey: "AIzaSyAlkTeBTBPtnVAaOnNmwiwsFVDIWKhfp5M", 5 | authDomain: "hackathon-mozofest-2019.firebaseapp.com", 6 | databaseURL: "https://hackathon-mozofest-2019.firebaseio.com", 7 | projectId: "hackathon-mozofest-2019", 8 | storageBucket: "hackathon-mozofest-2019.appspot.com", 9 | messagingSenderId: "835193922935" 10 | }; 11 | firebase.initializeApp(config); 12 | //clear any signed in users..... 13 | firebase.auth().signOut().then(function() { 14 | console.log("Sign out successful"); 15 | }).catch(function(error) { 16 | console.log("Error singing out"); 17 | }); 18 | 19 | function foo(){ 20 | 21 | console.log("working on FOO"); 22 | var email = document.getElementById("loginemail").value; 23 | var password = document.getElementById("loginpassword").value; 24 | 25 | firebase.auth().signInWithEmailAndPassword(email,password).catch(function(error) { //catch errors if any 26 | console.log(error); 27 | }).then(function(){ //when login is complete, only then..... 28 | var user = firebase.auth().currentUser; 29 | if(user!=null){ 30 | console.log("Faculty Login Success"); 31 | document.location.href = "dataEntry.html"; 32 | } 33 | else{ 34 | console.log("Login Unsuccessful"); 35 | M.toast({html: 'Invalid credentials! Please try again!'}); 36 | } 37 | }); 38 | console.log("outside"); 39 | 40 | } -------------------------------------------------------------------------------- /main/js/upload.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | 3 | function foo(){ 4 | var str = document.getElementById('studentregno').value; 5 | if(str.length>1){ 6 | console.log("Entered Reg. No. is " + str); 7 | console.log("attempting file write"); 8 | fs.writeFileSync('py/helper.txt', str, function (err,fd) { 9 | if (err) throw err; 10 | fs.close(fd, function(error) { 11 | if (error) { 12 | console.error("close error: " + error.message); 13 | } else { 14 | console.log("File was closed!"); 15 | } 16 | }); 17 | }); 18 | 19 | var python = require('child_process').spawn('python', ['py/capture.py']); 20 | python.stdout.on('data',function(data){ 21 | console.log("data: ",data.toString('utf8')+ " from Python "); 22 | }); 23 | } 24 | else{ 25 | M.toast({html:'All field are mandatory!'}); 26 | } 27 | } 28 | function Train(){ 29 | console.log("JS Train running"); 30 | document.getElementById('preloader').style.visibility="visible"; 31 | M.toast({html:'Training has begun, it might take some time. You will be informed when the job is complete.'}); 32 | var python = require('child_process').spawn('python', ['py/train.py']); 33 | python.stdout.on('data',function(data){ 34 | console.log("data: ",data.toString('utf8')+ " from Python "); 35 | M.toast({html:'Please upload the file found in /assests/models directory.'}); 36 | document.getElementById('preloader').style.visibility='hidden'; 37 | document.getElementById('trainfield').style.backgroundColor='red'; 38 | }); 39 | } 40 | //manual file upload 41 | var selectedFile; 42 | 43 | var config = { 44 | apiKey: "AIzaSyAlkTeBTBPtnVAaOnNmwiwsFVDIWKhfp5M", 45 | authDomain: "hackathon-mozofest-2019.firebaseapp.com", 46 | databaseURL: "https://hackathon-mozofest-2019.firebaseio.com", 47 | storageBucket: 'gs://hackathon-mozofest-2019.appspot.com/' 48 | }; 49 | firebase.initializeApp(config); 50 | var database = firebase.database(); 51 | 52 | function logOut(){ 53 | console.log("Attempting Sign Out"); 54 | firebase.auth().signOut().then(function() { 55 | console.log("Sign out successful"); 56 | document.location.href = "facultyLogin.html"; 57 | }).catch(function(error) { 58 | console.log("Error singing out"); 59 | }); 60 | } 61 | 62 | function uploadFile(){ 63 | M.toast({html:'Starting with the upload task'}); 64 | var filename = selectedFile.name; 65 | // var regno = document.getElementById('studentregno').value; 66 | // var sName = document.getElementById('studentname').value; 67 | var storageRef = firebase.storage().ref('/' + 'models' + '/' + filename); 68 | var uploadTask = storageRef.put(selectedFile); 69 | 70 | 71 | uploadTask.on('state_changed', function(snapshot){ 72 | // Observe state change events such as progress, pause, and resume 73 | // Get task progress, including the number of bytes uploaded and the total number of bytes to be uploaded 74 | var progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100; 75 | console.log('Upload is ' + progress + '% done'); 76 | document.getElementById("bar").style.width=progress+100; 77 | switch (snapshot.state) { 78 | case firebase.storage.TaskState.PAUSED: // or 'paused' 79 | console.log('Upload is paused'); 80 | break; 81 | case firebase.storage.TaskState.RUNNING: // or 'running' 82 | console.log('Upload is running'); 83 | break; 84 | } 85 | }, function(error) { 86 | // Handle unsuccessful uploads 87 | }, function() { 88 | // Handle successful uploads on complete 89 | // For instance, get the download URL: https://firebasestorage.googleapis.com/... 90 | uploadTask.snapshot.ref.getDownloadURL().then(function(downloadURL) { 91 | console.log('File available at', downloadURL); 92 | document.getElementById("bar").style.width="100%"; 93 | // writeUserData(regno,sName); 94 | M.toast({html:'Upload Task Successful!'}); 95 | }); 96 | }); 97 | 98 | 99 | }; 100 | 101 | function writeUserData() { 102 | 103 | var studregno = document.getElementById('studentregno').value; 104 | var studname = document.getElementById('studentname').value; 105 | if(studregno.length>2 && studname.length>2){ 106 | firebase.database().ref('Students/' + studregno).set({ 107 | RegNo: studregno, 108 | name: studname, 109 | hours_conducted: 0, 110 | hours_present:0, 111 | dayorder:{ 112 | DO1:0, 113 | DO2:0, 114 | DO3:0, 115 | }, 116 | 117 | }); 118 | console.log("All Data Sent Successfully"); 119 | M.toast({html:'Data has been uploaded to the server! You can continue adding more'}); 120 | } 121 | else{ 122 | console.log("Incorrect data detected, warning user"); 123 | M.toast({html:'All fields are mandatory'}); 124 | } 125 | 126 | } 127 | 128 | $("#file").on("change",function(event){ 129 | selectedFile = event.target.files[0]; 130 | uploadFile(); 131 | }); 132 | 133 | -------------------------------------------------------------------------------- /main/main.js: -------------------------------------------------------------------------------- 1 | const {app, BrowserWindow} = require('electron'); 2 | const path = require('path'); 3 | const url = require('url'); 4 | 5 | let win; 6 | 7 | function CreateWindow(){ 8 | win = new BrowserWindow({width:1920, height:1080, icon:__dirname+'/icon.png'}); 9 | 10 | win.loadURL(url.format({ 11 | pathname: path.join(__dirname, 'index.html'), 12 | protocol: 'file:', 13 | slashes: true 14 | })); 15 | 16 | 17 | console.log("WINDOWS CREATED"); 18 | 19 | // DEVELOPER TOOLS KE LIYE 20 | // win.webContents.openDevTools(); 21 | 22 | win.on('closed',() => { 23 | win=null; 24 | }); 25 | } 26 | app.on('ready', CreateWindow); 27 | 28 | app.on('window-all-closed',() => { 29 | if(process.platform !== 'darwin'){ 30 | app.quit(); 31 | } 32 | }); 33 | -------------------------------------------------------------------------------- /main/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mozohack", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@types/node": { 8 | "version": "10.14.4", 9 | "resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.4.tgz", 10 | "integrity": "sha512-DT25xX/YgyPKiHFOpNuANIQIVvYEwCWXgK2jYYwqgaMrYE6+tq+DtmMwlD3drl6DJbUwtlIDnn0d7tIn/EbXBg==" 11 | }, 12 | "ajv": { 13 | "version": "6.10.0", 14 | "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", 15 | "integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==", 16 | "requires": { 17 | "fast-deep-equal": "^2.0.1", 18 | "fast-json-stable-stringify": "^2.0.0", 19 | "json-schema-traverse": "^0.4.1", 20 | "uri-js": "^4.2.2" 21 | } 22 | }, 23 | "ansi-regex": { 24 | "version": "2.1.1", 25 | "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", 26 | "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" 27 | }, 28 | "array-find-index": { 29 | "version": "1.0.2", 30 | "resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz", 31 | "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=" 32 | }, 33 | "asn1": { 34 | "version": "0.2.4", 35 | "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", 36 | "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", 37 | "requires": { 38 | "safer-buffer": "~2.1.0" 39 | } 40 | }, 41 | "assert-plus": { 42 | "version": "1.0.0", 43 | "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", 44 | "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" 45 | }, 46 | "asynckit": { 47 | "version": "0.4.0", 48 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", 49 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" 50 | }, 51 | "aws-sign2": { 52 | "version": "0.7.0", 53 | "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", 54 | "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" 55 | }, 56 | "aws4": { 57 | "version": "1.8.0", 58 | "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", 59 | "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" 60 | }, 61 | "bcrypt-pbkdf": { 62 | "version": "1.0.2", 63 | "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", 64 | "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", 65 | "requires": { 66 | "tweetnacl": "^0.14.3" 67 | } 68 | }, 69 | "buffer-from": { 70 | "version": "1.1.1", 71 | "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", 72 | "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" 73 | }, 74 | "camelcase": { 75 | "version": "2.1.1", 76 | "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", 77 | "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=" 78 | }, 79 | "camelcase-keys": { 80 | "version": "2.1.0", 81 | "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", 82 | "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", 83 | "requires": { 84 | "camelcase": "^2.0.0", 85 | "map-obj": "^1.0.0" 86 | } 87 | }, 88 | "caseless": { 89 | "version": "0.12.0", 90 | "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", 91 | "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" 92 | }, 93 | "code-point-at": { 94 | "version": "1.1.0", 95 | "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", 96 | "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" 97 | }, 98 | "combined-stream": { 99 | "version": "1.0.7", 100 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", 101 | "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", 102 | "requires": { 103 | "delayed-stream": "~1.0.0" 104 | } 105 | }, 106 | "concat-stream": { 107 | "version": "1.6.2", 108 | "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", 109 | "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", 110 | "requires": { 111 | "buffer-from": "^1.0.0", 112 | "inherits": "^2.0.3", 113 | "readable-stream": "^2.2.2", 114 | "typedarray": "^0.0.6" 115 | }, 116 | "dependencies": { 117 | "isarray": { 118 | "version": "1.0.0", 119 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", 120 | "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" 121 | }, 122 | "readable-stream": { 123 | "version": "2.3.6", 124 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", 125 | "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", 126 | "requires": { 127 | "core-util-is": "~1.0.0", 128 | "inherits": "~2.0.3", 129 | "isarray": "~1.0.0", 130 | "process-nextick-args": "~2.0.0", 131 | "safe-buffer": "~5.1.1", 132 | "string_decoder": "~1.1.1", 133 | "util-deprecate": "~1.0.1" 134 | } 135 | }, 136 | "string_decoder": { 137 | "version": "1.1.1", 138 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", 139 | "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", 140 | "requires": { 141 | "safe-buffer": "~5.1.0" 142 | } 143 | } 144 | } 145 | }, 146 | "core-util-is": { 147 | "version": "1.0.2", 148 | "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", 149 | "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" 150 | }, 151 | "currently-unhandled": { 152 | "version": "0.4.1", 153 | "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", 154 | "integrity": "sha1-mI3zP+qxke95mmE2nddsF635V+o=", 155 | "requires": { 156 | "array-find-index": "^1.0.1" 157 | } 158 | }, 159 | "dashdash": { 160 | "version": "1.14.1", 161 | "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", 162 | "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", 163 | "requires": { 164 | "assert-plus": "^1.0.0" 165 | } 166 | }, 167 | "debug": { 168 | "version": "3.2.6", 169 | "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", 170 | "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", 171 | "requires": { 172 | "ms": "^2.1.1" 173 | } 174 | }, 175 | "decamelize": { 176 | "version": "1.2.0", 177 | "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", 178 | "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" 179 | }, 180 | "deep-extend": { 181 | "version": "0.6.0", 182 | "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", 183 | "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==" 184 | }, 185 | "delayed-stream": { 186 | "version": "1.0.0", 187 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", 188 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" 189 | }, 190 | "ecc-jsbn": { 191 | "version": "0.1.2", 192 | "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", 193 | "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", 194 | "requires": { 195 | "jsbn": "~0.1.0", 196 | "safer-buffer": "^2.1.0" 197 | } 198 | }, 199 | "electron": { 200 | "version": "4.1.3", 201 | "resolved": "https://registry.npmjs.org/electron/-/electron-4.1.3.tgz", 202 | "integrity": "sha512-oOeuA+BAydrMcKGBu4GEJfgAtaRd189SabE8V9koAH/sUiTHYroWtwRzA6V24JFa/dCJAHNjVD8F4qSMybxzrA==", 203 | "requires": { 204 | "@types/node": "^10.12.18", 205 | "electron-download": "^4.1.0", 206 | "extract-zip": "^1.0.3" 207 | } 208 | }, 209 | "electron-download": { 210 | "version": "4.1.1", 211 | "resolved": "https://registry.npmjs.org/electron-download/-/electron-download-4.1.1.tgz", 212 | "integrity": "sha512-FjEWG9Jb/ppK/2zToP+U5dds114fM1ZOJqMAR4aXXL5CvyPE9fiqBK/9YcwC9poIFQTEJk/EM/zyRwziziRZrg==", 213 | "requires": { 214 | "debug": "^3.0.0", 215 | "env-paths": "^1.0.0", 216 | "fs-extra": "^4.0.1", 217 | "minimist": "^1.2.0", 218 | "nugget": "^2.0.1", 219 | "path-exists": "^3.0.0", 220 | "rc": "^1.2.1", 221 | "semver": "^5.4.1", 222 | "sumchecker": "^2.0.2" 223 | } 224 | }, 225 | "env-paths": { 226 | "version": "1.0.0", 227 | "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-1.0.0.tgz", 228 | "integrity": "sha1-QWgTO0K7BcOKNbGuQ5fIKYqzaeA=" 229 | }, 230 | "error-ex": { 231 | "version": "1.3.2", 232 | "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", 233 | "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", 234 | "requires": { 235 | "is-arrayish": "^0.2.1" 236 | } 237 | }, 238 | "extend": { 239 | "version": "3.0.2", 240 | "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", 241 | "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" 242 | }, 243 | "extract-zip": { 244 | "version": "1.6.7", 245 | "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.7.tgz", 246 | "integrity": "sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k=", 247 | "requires": { 248 | "concat-stream": "1.6.2", 249 | "debug": "2.6.9", 250 | "mkdirp": "0.5.1", 251 | "yauzl": "2.4.1" 252 | }, 253 | "dependencies": { 254 | "debug": { 255 | "version": "2.6.9", 256 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 257 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", 258 | "requires": { 259 | "ms": "2.0.0" 260 | } 261 | }, 262 | "ms": { 263 | "version": "2.0.0", 264 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 265 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" 266 | } 267 | } 268 | }, 269 | "extsprintf": { 270 | "version": "1.3.0", 271 | "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", 272 | "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" 273 | }, 274 | "fast-deep-equal": { 275 | "version": "2.0.1", 276 | "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", 277 | "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" 278 | }, 279 | "fast-json-stable-stringify": { 280 | "version": "2.0.0", 281 | "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", 282 | "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" 283 | }, 284 | "fd-slicer": { 285 | "version": "1.0.1", 286 | "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz", 287 | "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=", 288 | "requires": { 289 | "pend": "~1.2.0" 290 | } 291 | }, 292 | "find-up": { 293 | "version": "1.1.2", 294 | "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", 295 | "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", 296 | "requires": { 297 | "path-exists": "^2.0.0", 298 | "pinkie-promise": "^2.0.0" 299 | }, 300 | "dependencies": { 301 | "path-exists": { 302 | "version": "2.1.0", 303 | "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", 304 | "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", 305 | "requires": { 306 | "pinkie-promise": "^2.0.0" 307 | } 308 | } 309 | } 310 | }, 311 | "forever-agent": { 312 | "version": "0.6.1", 313 | "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", 314 | "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" 315 | }, 316 | "form-data": { 317 | "version": "2.3.3", 318 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", 319 | "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", 320 | "requires": { 321 | "asynckit": "^0.4.0", 322 | "combined-stream": "^1.0.6", 323 | "mime-types": "^2.1.12" 324 | } 325 | }, 326 | "fs-extra": { 327 | "version": "4.0.3", 328 | "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", 329 | "integrity": "sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==", 330 | "requires": { 331 | "graceful-fs": "^4.1.2", 332 | "jsonfile": "^4.0.0", 333 | "universalify": "^0.1.0" 334 | } 335 | }, 336 | "get-stdin": { 337 | "version": "4.0.1", 338 | "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", 339 | "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=" 340 | }, 341 | "getpass": { 342 | "version": "0.1.7", 343 | "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", 344 | "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", 345 | "requires": { 346 | "assert-plus": "^1.0.0" 347 | } 348 | }, 349 | "graceful-fs": { 350 | "version": "4.1.15", 351 | "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", 352 | "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==" 353 | }, 354 | "har-schema": { 355 | "version": "2.0.0", 356 | "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", 357 | "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" 358 | }, 359 | "har-validator": { 360 | "version": "5.1.3", 361 | "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", 362 | "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", 363 | "requires": { 364 | "ajv": "^6.5.5", 365 | "har-schema": "^2.0.0" 366 | } 367 | }, 368 | "hosted-git-info": { 369 | "version": "2.7.1", 370 | "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz", 371 | "integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==" 372 | }, 373 | "http-signature": { 374 | "version": "1.2.0", 375 | "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", 376 | "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", 377 | "requires": { 378 | "assert-plus": "^1.0.0", 379 | "jsprim": "^1.2.2", 380 | "sshpk": "^1.7.0" 381 | } 382 | }, 383 | "indent-string": { 384 | "version": "2.1.0", 385 | "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", 386 | "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", 387 | "requires": { 388 | "repeating": "^2.0.0" 389 | } 390 | }, 391 | "inherits": { 392 | "version": "2.0.3", 393 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 394 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" 395 | }, 396 | "ini": { 397 | "version": "1.3.5", 398 | "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", 399 | "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" 400 | }, 401 | "is-arrayish": { 402 | "version": "0.2.1", 403 | "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", 404 | "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=" 405 | }, 406 | "is-finite": { 407 | "version": "1.0.2", 408 | "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", 409 | "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", 410 | "requires": { 411 | "number-is-nan": "^1.0.0" 412 | } 413 | }, 414 | "is-fullwidth-code-point": { 415 | "version": "1.0.0", 416 | "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", 417 | "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", 418 | "requires": { 419 | "number-is-nan": "^1.0.0" 420 | } 421 | }, 422 | "is-typedarray": { 423 | "version": "1.0.0", 424 | "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", 425 | "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" 426 | }, 427 | "is-utf8": { 428 | "version": "0.2.1", 429 | "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", 430 | "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=" 431 | }, 432 | "isarray": { 433 | "version": "0.0.1", 434 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", 435 | "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" 436 | }, 437 | "isstream": { 438 | "version": "0.1.2", 439 | "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", 440 | "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" 441 | }, 442 | "jquery": { 443 | "version": "3.3.1", 444 | "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.3.1.tgz", 445 | "integrity": "sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg==" 446 | }, 447 | "jsbn": { 448 | "version": "0.1.1", 449 | "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", 450 | "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" 451 | }, 452 | "json-schema": { 453 | "version": "0.2.3", 454 | "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", 455 | "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" 456 | }, 457 | "json-schema-traverse": { 458 | "version": "0.4.1", 459 | "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", 460 | "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" 461 | }, 462 | "json-stringify-safe": { 463 | "version": "5.0.1", 464 | "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", 465 | "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" 466 | }, 467 | "jsonfile": { 468 | "version": "4.0.0", 469 | "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", 470 | "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", 471 | "requires": { 472 | "graceful-fs": "^4.1.6" 473 | } 474 | }, 475 | "jsprim": { 476 | "version": "1.4.1", 477 | "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", 478 | "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", 479 | "requires": { 480 | "assert-plus": "1.0.0", 481 | "extsprintf": "1.3.0", 482 | "json-schema": "0.2.3", 483 | "verror": "1.10.0" 484 | } 485 | }, 486 | "load-json-file": { 487 | "version": "1.1.0", 488 | "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", 489 | "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", 490 | "requires": { 491 | "graceful-fs": "^4.1.2", 492 | "parse-json": "^2.2.0", 493 | "pify": "^2.0.0", 494 | "pinkie-promise": "^2.0.0", 495 | "strip-bom": "^2.0.0" 496 | } 497 | }, 498 | "loud-rejection": { 499 | "version": "1.6.0", 500 | "resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz", 501 | "integrity": "sha1-W0b4AUft7leIcPCG0Eghz5mOVR8=", 502 | "requires": { 503 | "currently-unhandled": "^0.4.1", 504 | "signal-exit": "^3.0.0" 505 | } 506 | }, 507 | "map-obj": { 508 | "version": "1.0.1", 509 | "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", 510 | "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=" 511 | }, 512 | "meow": { 513 | "version": "3.7.0", 514 | "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", 515 | "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", 516 | "requires": { 517 | "camelcase-keys": "^2.0.0", 518 | "decamelize": "^1.1.2", 519 | "loud-rejection": "^1.0.0", 520 | "map-obj": "^1.0.1", 521 | "minimist": "^1.1.3", 522 | "normalize-package-data": "^2.3.4", 523 | "object-assign": "^4.0.1", 524 | "read-pkg-up": "^1.0.1", 525 | "redent": "^1.0.0", 526 | "trim-newlines": "^1.0.0" 527 | } 528 | }, 529 | "mime-db": { 530 | "version": "1.38.0", 531 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.38.0.tgz", 532 | "integrity": "sha512-bqVioMFFzc2awcdJZIzR3HjZFX20QhilVS7hytkKrv7xFAn8bM1gzc/FOX2awLISvWe0PV8ptFKcon+wZ5qYkg==" 533 | }, 534 | "mime-types": { 535 | "version": "2.1.22", 536 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.22.tgz", 537 | "integrity": "sha512-aGl6TZGnhm/li6F7yx82bJiBZwgiEa4Hf6CNr8YO+r5UHr53tSTYZb102zyU50DOWWKeOv0uQLRL0/9EiKWCog==", 538 | "requires": { 539 | "mime-db": "~1.38.0" 540 | } 541 | }, 542 | "minimist": { 543 | "version": "1.2.0", 544 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", 545 | "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" 546 | }, 547 | "mkdirp": { 548 | "version": "0.5.1", 549 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", 550 | "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", 551 | "requires": { 552 | "minimist": "0.0.8" 553 | }, 554 | "dependencies": { 555 | "minimist": { 556 | "version": "0.0.8", 557 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", 558 | "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" 559 | } 560 | } 561 | }, 562 | "ms": { 563 | "version": "2.1.1", 564 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", 565 | "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" 566 | }, 567 | "normalize-package-data": { 568 | "version": "2.5.0", 569 | "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", 570 | "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", 571 | "requires": { 572 | "hosted-git-info": "^2.1.4", 573 | "resolve": "^1.10.0", 574 | "semver": "2 || 3 || 4 || 5", 575 | "validate-npm-package-license": "^3.0.1" 576 | } 577 | }, 578 | "nugget": { 579 | "version": "2.0.1", 580 | "resolved": "https://registry.npmjs.org/nugget/-/nugget-2.0.1.tgz", 581 | "integrity": "sha1-IBCVpIfhrTYIGzQy+jytpPjQcbA=", 582 | "requires": { 583 | "debug": "^2.1.3", 584 | "minimist": "^1.1.0", 585 | "pretty-bytes": "^1.0.2", 586 | "progress-stream": "^1.1.0", 587 | "request": "^2.45.0", 588 | "single-line-log": "^1.1.2", 589 | "throttleit": "0.0.2" 590 | }, 591 | "dependencies": { 592 | "debug": { 593 | "version": "2.6.9", 594 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 595 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", 596 | "requires": { 597 | "ms": "2.0.0" 598 | } 599 | }, 600 | "ms": { 601 | "version": "2.0.0", 602 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 603 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" 604 | } 605 | } 606 | }, 607 | "number-is-nan": { 608 | "version": "1.0.1", 609 | "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", 610 | "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" 611 | }, 612 | "oauth-sign": { 613 | "version": "0.9.0", 614 | "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", 615 | "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" 616 | }, 617 | "object-assign": { 618 | "version": "4.1.1", 619 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 620 | "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" 621 | }, 622 | "object-keys": { 623 | "version": "0.4.0", 624 | "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz", 625 | "integrity": "sha1-KKaq50KN0sOpLz2V8hM13SBOAzY=" 626 | }, 627 | "parse-json": { 628 | "version": "2.2.0", 629 | "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", 630 | "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", 631 | "requires": { 632 | "error-ex": "^1.2.0" 633 | } 634 | }, 635 | "path-exists": { 636 | "version": "3.0.0", 637 | "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", 638 | "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" 639 | }, 640 | "path-parse": { 641 | "version": "1.0.6", 642 | "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", 643 | "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" 644 | }, 645 | "path-type": { 646 | "version": "1.1.0", 647 | "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", 648 | "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", 649 | "requires": { 650 | "graceful-fs": "^4.1.2", 651 | "pify": "^2.0.0", 652 | "pinkie-promise": "^2.0.0" 653 | } 654 | }, 655 | "pend": { 656 | "version": "1.2.0", 657 | "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", 658 | "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=" 659 | }, 660 | "performance-now": { 661 | "version": "2.1.0", 662 | "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", 663 | "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" 664 | }, 665 | "pify": { 666 | "version": "2.3.0", 667 | "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", 668 | "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" 669 | }, 670 | "pinkie": { 671 | "version": "2.0.4", 672 | "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", 673 | "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=" 674 | }, 675 | "pinkie-promise": { 676 | "version": "2.0.1", 677 | "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", 678 | "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", 679 | "requires": { 680 | "pinkie": "^2.0.0" 681 | } 682 | }, 683 | "pretty-bytes": { 684 | "version": "1.0.4", 685 | "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-1.0.4.tgz", 686 | "integrity": "sha1-CiLoIQYJrTVUL4yNXSFZr/B1HIQ=", 687 | "requires": { 688 | "get-stdin": "^4.0.1", 689 | "meow": "^3.1.0" 690 | } 691 | }, 692 | "process-nextick-args": { 693 | "version": "2.0.0", 694 | "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", 695 | "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" 696 | }, 697 | "progress-stream": { 698 | "version": "1.2.0", 699 | "resolved": "https://registry.npmjs.org/progress-stream/-/progress-stream-1.2.0.tgz", 700 | "integrity": "sha1-LNPP6jO6OonJwSHsM0er6asSX3c=", 701 | "requires": { 702 | "speedometer": "~0.1.2", 703 | "through2": "~0.2.3" 704 | } 705 | }, 706 | "psl": { 707 | "version": "1.1.31", 708 | "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz", 709 | "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==" 710 | }, 711 | "punycode": { 712 | "version": "2.1.1", 713 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", 714 | "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" 715 | }, 716 | "python-shell": { 717 | "version": "1.0.7", 718 | "resolved": "https://registry.npmjs.org/python-shell/-/python-shell-1.0.7.tgz", 719 | "integrity": "sha512-k6s27Uj5WEAxFLRKLFUvlDCm1GpkmAQ4vg9CASgqwbHqAM1d1x3nh3bzlBKgmRwNDeLlu0DP41CqwRZn1DKtuA==" 720 | }, 721 | "qs": { 722 | "version": "6.5.2", 723 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", 724 | "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" 725 | }, 726 | "rc": { 727 | "version": "1.2.8", 728 | "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", 729 | "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", 730 | "requires": { 731 | "deep-extend": "^0.6.0", 732 | "ini": "~1.3.0", 733 | "minimist": "^1.2.0", 734 | "strip-json-comments": "~2.0.1" 735 | } 736 | }, 737 | "read-pkg": { 738 | "version": "1.1.0", 739 | "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", 740 | "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", 741 | "requires": { 742 | "load-json-file": "^1.0.0", 743 | "normalize-package-data": "^2.3.2", 744 | "path-type": "^1.0.0" 745 | } 746 | }, 747 | "read-pkg-up": { 748 | "version": "1.0.1", 749 | "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", 750 | "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", 751 | "requires": { 752 | "find-up": "^1.0.0", 753 | "read-pkg": "^1.0.0" 754 | } 755 | }, 756 | "readable-stream": { 757 | "version": "1.1.14", 758 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", 759 | "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", 760 | "requires": { 761 | "core-util-is": "~1.0.0", 762 | "inherits": "~2.0.1", 763 | "isarray": "0.0.1", 764 | "string_decoder": "~0.10.x" 765 | } 766 | }, 767 | "redent": { 768 | "version": "1.0.0", 769 | "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz", 770 | "integrity": "sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94=", 771 | "requires": { 772 | "indent-string": "^2.1.0", 773 | "strip-indent": "^1.0.1" 774 | } 775 | }, 776 | "repeating": { 777 | "version": "2.0.1", 778 | "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", 779 | "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", 780 | "requires": { 781 | "is-finite": "^1.0.0" 782 | } 783 | }, 784 | "request": { 785 | "version": "2.88.0", 786 | "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", 787 | "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", 788 | "requires": { 789 | "aws-sign2": "~0.7.0", 790 | "aws4": "^1.8.0", 791 | "caseless": "~0.12.0", 792 | "combined-stream": "~1.0.6", 793 | "extend": "~3.0.2", 794 | "forever-agent": "~0.6.1", 795 | "form-data": "~2.3.2", 796 | "har-validator": "~5.1.0", 797 | "http-signature": "~1.2.0", 798 | "is-typedarray": "~1.0.0", 799 | "isstream": "~0.1.2", 800 | "json-stringify-safe": "~5.0.1", 801 | "mime-types": "~2.1.19", 802 | "oauth-sign": "~0.9.0", 803 | "performance-now": "^2.1.0", 804 | "qs": "~6.5.2", 805 | "safe-buffer": "^5.1.2", 806 | "tough-cookie": "~2.4.3", 807 | "tunnel-agent": "^0.6.0", 808 | "uuid": "^3.3.2" 809 | } 810 | }, 811 | "resolve": { 812 | "version": "1.10.0", 813 | "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.0.tgz", 814 | "integrity": "sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg==", 815 | "requires": { 816 | "path-parse": "^1.0.6" 817 | } 818 | }, 819 | "safe-buffer": { 820 | "version": "5.1.2", 821 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", 822 | "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" 823 | }, 824 | "safer-buffer": { 825 | "version": "2.1.2", 826 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", 827 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" 828 | }, 829 | "semver": { 830 | "version": "5.7.0", 831 | "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", 832 | "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==" 833 | }, 834 | "signal-exit": { 835 | "version": "3.0.2", 836 | "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", 837 | "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" 838 | }, 839 | "single-line-log": { 840 | "version": "1.1.2", 841 | "resolved": "https://registry.npmjs.org/single-line-log/-/single-line-log-1.1.2.tgz", 842 | "integrity": "sha1-wvg/Jzo+GhbtsJlWYdoO1e8DM2Q=", 843 | "requires": { 844 | "string-width": "^1.0.1" 845 | } 846 | }, 847 | "spdx-correct": { 848 | "version": "3.1.0", 849 | "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz", 850 | "integrity": "sha512-lr2EZCctC2BNR7j7WzJ2FpDznxky1sjfxvvYEyzxNyb6lZXHODmEoJeFu4JupYlkfha1KZpJyoqiJ7pgA1qq8Q==", 851 | "requires": { 852 | "spdx-expression-parse": "^3.0.0", 853 | "spdx-license-ids": "^3.0.0" 854 | } 855 | }, 856 | "spdx-exceptions": { 857 | "version": "2.2.0", 858 | "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz", 859 | "integrity": "sha512-2XQACfElKi9SlVb1CYadKDXvoajPgBVPn/gOQLrTvHdElaVhr7ZEbqJaRnJLVNeaI4cMEAgVCeBMKF6MWRDCRA==" 860 | }, 861 | "spdx-expression-parse": { 862 | "version": "3.0.0", 863 | "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", 864 | "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", 865 | "requires": { 866 | "spdx-exceptions": "^2.1.0", 867 | "spdx-license-ids": "^3.0.0" 868 | } 869 | }, 870 | "spdx-license-ids": { 871 | "version": "3.0.3", 872 | "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.3.tgz", 873 | "integrity": "sha512-uBIcIl3Ih6Phe3XHK1NqboJLdGfwr1UN3k6wSD1dZpmPsIkb8AGNbZYJ1fOBk834+Gxy8rpfDxrS6XLEMZMY2g==" 874 | }, 875 | "speedometer": { 876 | "version": "0.1.4", 877 | "resolved": "https://registry.npmjs.org/speedometer/-/speedometer-0.1.4.tgz", 878 | "integrity": "sha1-mHbb0qFp0xFUAtSObqYynIgWpQ0=" 879 | }, 880 | "sshpk": { 881 | "version": "1.16.1", 882 | "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", 883 | "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", 884 | "requires": { 885 | "asn1": "~0.2.3", 886 | "assert-plus": "^1.0.0", 887 | "bcrypt-pbkdf": "^1.0.0", 888 | "dashdash": "^1.12.0", 889 | "ecc-jsbn": "~0.1.1", 890 | "getpass": "^0.1.1", 891 | "jsbn": "~0.1.0", 892 | "safer-buffer": "^2.0.2", 893 | "tweetnacl": "~0.14.0" 894 | } 895 | }, 896 | "string-width": { 897 | "version": "1.0.2", 898 | "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", 899 | "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", 900 | "requires": { 901 | "code-point-at": "^1.0.0", 902 | "is-fullwidth-code-point": "^1.0.0", 903 | "strip-ansi": "^3.0.0" 904 | } 905 | }, 906 | "string_decoder": { 907 | "version": "0.10.31", 908 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", 909 | "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" 910 | }, 911 | "strip-ansi": { 912 | "version": "3.0.1", 913 | "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", 914 | "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", 915 | "requires": { 916 | "ansi-regex": "^2.0.0" 917 | } 918 | }, 919 | "strip-bom": { 920 | "version": "2.0.0", 921 | "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", 922 | "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", 923 | "requires": { 924 | "is-utf8": "^0.2.0" 925 | } 926 | }, 927 | "strip-indent": { 928 | "version": "1.0.1", 929 | "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz", 930 | "integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=", 931 | "requires": { 932 | "get-stdin": "^4.0.1" 933 | } 934 | }, 935 | "strip-json-comments": { 936 | "version": "2.0.1", 937 | "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", 938 | "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" 939 | }, 940 | "sumchecker": { 941 | "version": "2.0.2", 942 | "resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-2.0.2.tgz", 943 | "integrity": "sha1-D0LBDl0F2l1C7qPlbDOZo31sWz4=", 944 | "requires": { 945 | "debug": "^2.2.0" 946 | }, 947 | "dependencies": { 948 | "debug": { 949 | "version": "2.6.9", 950 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 951 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", 952 | "requires": { 953 | "ms": "2.0.0" 954 | } 955 | }, 956 | "ms": { 957 | "version": "2.0.0", 958 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 959 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" 960 | } 961 | } 962 | }, 963 | "throttleit": { 964 | "version": "0.0.2", 965 | "resolved": "https://registry.npmjs.org/throttleit/-/throttleit-0.0.2.tgz", 966 | "integrity": "sha1-z+34jmDADdlpe2H90qg0OptoDq8=" 967 | }, 968 | "through2": { 969 | "version": "0.2.3", 970 | "resolved": "https://registry.npmjs.org/through2/-/through2-0.2.3.tgz", 971 | "integrity": "sha1-6zKE2k6jEbbMis42U3SKUqvyWj8=", 972 | "requires": { 973 | "readable-stream": "~1.1.9", 974 | "xtend": "~2.1.1" 975 | } 976 | }, 977 | "tough-cookie": { 978 | "version": "2.4.3", 979 | "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", 980 | "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", 981 | "requires": { 982 | "psl": "^1.1.24", 983 | "punycode": "^1.4.1" 984 | }, 985 | "dependencies": { 986 | "punycode": { 987 | "version": "1.4.1", 988 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", 989 | "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" 990 | } 991 | } 992 | }, 993 | "trim-newlines": { 994 | "version": "1.0.0", 995 | "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", 996 | "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=" 997 | }, 998 | "tunnel-agent": { 999 | "version": "0.6.0", 1000 | "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", 1001 | "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", 1002 | "requires": { 1003 | "safe-buffer": "^5.0.1" 1004 | } 1005 | }, 1006 | "tweetnacl": { 1007 | "version": "0.14.5", 1008 | "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", 1009 | "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" 1010 | }, 1011 | "typedarray": { 1012 | "version": "0.0.6", 1013 | "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", 1014 | "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" 1015 | }, 1016 | "universalify": { 1017 | "version": "0.1.2", 1018 | "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", 1019 | "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" 1020 | }, 1021 | "uri-js": { 1022 | "version": "4.2.2", 1023 | "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", 1024 | "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", 1025 | "requires": { 1026 | "punycode": "^2.1.0" 1027 | } 1028 | }, 1029 | "util-deprecate": { 1030 | "version": "1.0.2", 1031 | "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 1032 | "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" 1033 | }, 1034 | "uuid": { 1035 | "version": "3.3.2", 1036 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", 1037 | "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" 1038 | }, 1039 | "validate-npm-package-license": { 1040 | "version": "3.0.4", 1041 | "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", 1042 | "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", 1043 | "requires": { 1044 | "spdx-correct": "^3.0.0", 1045 | "spdx-expression-parse": "^3.0.0" 1046 | } 1047 | }, 1048 | "verror": { 1049 | "version": "1.10.0", 1050 | "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", 1051 | "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", 1052 | "requires": { 1053 | "assert-plus": "^1.0.0", 1054 | "core-util-is": "1.0.2", 1055 | "extsprintf": "^1.2.0" 1056 | } 1057 | }, 1058 | "xtend": { 1059 | "version": "2.1.2", 1060 | "resolved": "https://registry.npmjs.org/xtend/-/xtend-2.1.2.tgz", 1061 | "integrity": "sha1-bv7MKk2tjmlixJAbM3znuoe10os=", 1062 | "requires": { 1063 | "object-keys": "~0.4.0" 1064 | } 1065 | }, 1066 | "yauzl": { 1067 | "version": "2.4.1", 1068 | "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz", 1069 | "integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=", 1070 | "requires": { 1071 | "fd-slicer": "~1.0.1" 1072 | } 1073 | } 1074 | } 1075 | } 1076 | -------------------------------------------------------------------------------- /main/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mozohack", 3 | "version": "1.0.0", 4 | "description": "Automatic Attendance System for institutions", 5 | "main": "main.js", 6 | "scripts": { 7 | "start": "electron ." 8 | }, 9 | "author": "Shantnu Agarwal", 10 | "license": "ISC", 11 | "dependencies": { 12 | "electron": "^4.1.3", 13 | "jquery": "^3.3.1", 14 | "python-shell": "^1.0.7" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /main/py/camcap2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | 4 | # In[7]: 5 | 6 | 7 | import math 8 | import cv2 9 | import time 10 | from sklearn import neighbors 11 | import numpy as np 12 | import pandas as pd 13 | import os 14 | import os.path 15 | import pickle 16 | from PIL import Image, ImageDraw 17 | import face_recognition 18 | import requests 19 | from face_recognition.face_recognition_cli import image_files_in_folder 20 | curd = os.getcwd() 21 | 22 | try: 23 | os.mkdir("{}/models".format(curd)) 24 | except: 25 | pass 26 | names=[] 27 | ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg'} 28 | 29 | 30 | # In[8]: 31 | 32 | import shutil 33 | folder='{}/assets/test/'.format(curd) 34 | dest='{}/assets/History/'.format(curd) 35 | for i in os.listdir(folder): 36 | shutil.move(folder+i,dest) 37 | # file_path=os.path.join(folder,i) 38 | # if os.path.isfile(file_path): 39 | # os.remove(file_path) 40 | # In[9]: 41 | 42 | 43 | 44 | cap = cv2.VideoCapture(0) 45 | cap.set(cv2.CAP_PROP_FPS, 100) 46 | rat, frame = cap.read() 47 | count=0 48 | while count<10: 49 | curtime = time.strftime("%Y_%m_%d-%H_%M_%S") 50 | rat, frame = cap.read() 51 | cv2.imwrite("{}/assets/test/{}.jpg".format(curd,curtime), frame) 52 | count+=1 53 | cv2.imshow('img',frame) 54 | if cv2.waitKey(1) & 0xFF == ord('q'): 55 | break 56 | time.sleep(5) 57 | 58 | 59 | cap.release() 60 | cv2.destroyAllWindows() 61 | 62 | 63 | # In[10]: 64 | 65 | 66 | def predict(frame, knn_clf=None, model_path=None, distance_threshold=0.6): 67 | 68 | 69 | if knn_clf is None and model_path is None: 70 | raise Exception("Must supply knn classifier either thourgh knn_clf or model_path") 71 | 72 | if knn_clf is None: 73 | with open(model_path, 'rb') as f: 74 | knn_clf = pickle.load(f) 75 | 76 | 77 | # X_img = face_recognition.load_image_file(X_img_path) 78 | X_img = frame 79 | X_face_locations = face_recognition.face_locations(X_img) 80 | 81 | if len(X_face_locations) == 0: 82 | return [] 83 | 84 | faces_encodings = face_recognition.face_encodings(X_img, known_face_locations=X_face_locations) 85 | 86 | closest_distances = knn_clf.kneighbors(faces_encodings, n_neighbors=1) 87 | are_matches = [closest_distances[0][i][0] <= distance_threshold for i in range(len(X_face_locations))] 88 | 89 | return [(pred, loc) if rec else ("unknown", loc) for pred, loc, rec in zip(knn_clf.predict(faces_encodings), X_face_locations, are_matches)] 90 | 91 | 92 | # In[11]: 93 | 94 | 95 | def show_prediction_labels_on_image(frame, predictions): 96 | 97 | #pil_image = Image.open(img_path).convert("RGB") 98 | pil_image = Image.fromarray(frame).convert("RGB") 99 | draw = ImageDraw.Draw(pil_image) 100 | 101 | for name, (top, right, bottom, left) in predictions: 102 | draw.rectangle(((left, top), (right, bottom)), outline=(0, 0, 255)) 103 | 104 | 105 | name = name.encode("UTF-8") 106 | 107 | text_width, text_height = draw.textsize(name) 108 | draw.rectangle(((left, bottom - text_height - 10), (right, bottom)), fill=(0, 0, 255), outline=(0, 0, 255)) 109 | draw.text((left + 6, bottom - text_height - 5), name, fill=(255, 255, 255, 255)) 110 | 111 | del draw 112 | 113 | #pil_image.show() 114 | #cv2.imshow("frame",pil_image) 115 | return np.asarray(pil_image) 116 | 117 | 118 | # In[15]: 119 | 120 | 121 | for image_file in os.listdir(r"{}\assets\test".format(curd)): 122 | full_file_path = os.path.join(r"{}\assets\test".format(curd), image_file) 123 | 124 | print("Looking for faces in {}".format(image_file)) 125 | frame = cv2.imread(full_file_path,-1) 126 | 127 | predictions = predict(frame, model_path=r"{}\assets\models\trained_knn_model.clf".format(curd)) 128 | 129 | for name, (top, right, bottom, left) in predictions: 130 | print("- Found {} at ({}, {})".format(name, left, top)) 131 | names.append(name) 132 | # Display results overlaid on an image 133 | #show_prediction_labels_on_image(frame, predictions) 134 | final_img = show_prediction_labels_on_image(frame, predictions) 135 | cv2.imshow("X",final_img) 136 | cv2.waitKey(1) 137 | cv2.destroyAllWindows() 138 | 139 | 140 | # In[16]: 141 | 142 | 143 | namesD=pd.DataFrame(names, columns=["Names"]) 144 | namesD= namesD[namesD.Names!="unknown"] 145 | 146 | attendance= pd.DataFrame(namesD.iloc[:,0].value_counts()) 147 | attendance.rename(index=str,columns={'Names': 'Count'},inplace=True) 148 | attendance["Present"] =0 149 | 150 | attendance["Count"][0] > 5 151 | for i in range(attendance.shape[0]): 152 | if(attendance["Count"][i] > 5): 153 | attendance["Present"][i] =1 154 | 155 | 156 | attendance_final=attendance.drop(['Count'],axis=1) 157 | attendance_final 158 | attendance_final.to_csv('Attendance.csv') 159 | 160 | 161 | # In[ ]: 162 | 163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /main/py/camcapture.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | 4 | # In[ ]: 5 | 6 | 7 | import math 8 | import cv2 9 | import time 10 | from sklearn import neighbors 11 | import numpy as np 12 | import pandas as pd 13 | import os 14 | import os.path 15 | import pickle 16 | from PIL import Image, ImageDraw 17 | import face_recognition 18 | from face_recognition.face_recognition_cli import image_files_in_folder 19 | curd = os.getcwd() 20 | 21 | 22 | names=[] 23 | ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg'} 24 | 25 | 26 | # In[ ]: 27 | 28 | 29 | cap = cv2.VideoCapture(0) 30 | cap.set(cv2.CAP_PROP_FPS, 100) 31 | rat, frame = cap.read() 32 | count=0 33 | while count<10: 34 | curtime = time.strftime("%Y_%m_%d-%H_%M_%S") 35 | rat, frame = cap.read() 36 | cv2.imwrite("{}/assets/test/{}.jpg".format(curd,curtime), frame) 37 | count+=1 38 | cv2.imshow('img',frame) 39 | if cv2.waitKey(1) & 0xFF == ord('q'): 40 | break 41 | time.sleep(1) 42 | 43 | 44 | cap.release() 45 | cv2.destroyAllWindows() 46 | 47 | 48 | # In[ ]: 49 | 50 | 51 | def predict(frame, knn_clf=None, model_path=None, distance_threshold=0.5): 52 | 53 | 54 | if knn_clf is None and model_path is None: 55 | raise Exception("Must supply knn classifier either thourgh knn_clf or model_path") 56 | 57 | if knn_clf is None: 58 | with open(model_path, 'rb') as f: 59 | knn_clf = pickle.load(f) 60 | 61 | 62 | # X_img = face_recognition.load_image_file(X_img_path) 63 | X_img = frame 64 | X_face_locations = face_recognition.face_locations(X_img) 65 | 66 | if len(X_face_locations) == 0: 67 | return [] 68 | 69 | faces_encodings = face_recognition.face_encodings(X_img, known_face_locations=X_face_locations) 70 | 71 | closest_distances = knn_clf.kneighbors(faces_encodings, n_neighbors=1) 72 | are_matches = [closest_distances[0][i][0] <= distance_threshold for i in range(len(X_face_locations))] 73 | 74 | return [(pred, loc) if rec else ("unknown", loc) for pred, loc, rec in zip(knn_clf.predict(faces_encodings), X_face_locations, are_matches)] 75 | 76 | 77 | # In[ ]: 78 | 79 | 80 | # def show_prediction_labels_on_image(frame, predictions): 81 | 82 | # #pil_image = Image.open(img_path).convert("RGB") 83 | # pil_image = Image.fromarray(frame).convert("RGB") 84 | # draw = ImageDraw.Draw(pil_image) 85 | 86 | # for name, (top, right, bottom, left) in predictions: 87 | # draw.rectangle(((left, top), (right, bottom)), outline=(0, 0, 255)) 88 | 89 | 90 | # name = name.encode("UTF-8") 91 | 92 | # text_width, text_height = draw.textsize(name) 93 | # draw.rectangle(((left, bottom - text_height - 10), (right, bottom)), fill=(0, 0, 255), outline=(0, 0, 255)) 94 | # draw.text((left + 6, bottom - text_height - 5), name, fill=(255, 255, 255, 255)) 95 | 96 | # del draw 97 | 98 | # #pil_image.show() 99 | # #cv2.imshow("frame",pil_image) 100 | # return np.asarray(pil_image) 101 | 102 | 103 | # In[ ]: 104 | 105 | 106 | for image_file in os.listdir("{}/assets/test".format(curd)): 107 | full_file_path = os.path.join("{}/assests/test".format(curd), image_file) 108 | cv2.imshow(img_file) 109 | print("Looking for faces in {}".format(image_file)) 110 | frame = cv2.imread(full_file_path,-1) 111 | 112 | predictions = predict(frame, model_path="{}/assets/models/trained_knn_model.clf".format(curd)) 113 | 114 | for name, (top, right, bottom, left) in predictions: 115 | print("- Found {} at ({}, {})".format(name, left, top)) 116 | names.append(name) 117 | # Display results overlaid on an image 118 | #show_prediction_labels_on_image(frame, predictions) 119 | 120 | 121 | 122 | # In[ ]: 123 | 124 | 125 | namesD=pd.DataFrame(names, columns=["Names"]) 126 | namesD= namesD[namesD.Names!="unknown"] 127 | 128 | attendance= pd.DataFrame(namesD.iloc[:,0].value_counts()) 129 | attendance.rename(index=str,columns={'Names': 'Count'},inplace=True) 130 | attendance["Present"] =0 131 | 132 | attendance["Count"][0] > 5 133 | for i in range(attendance.shape[0]): 134 | if(attendance["Count"][i] > 5): 135 | attendance["Present"][i] =1 136 | 137 | 138 | attendance_final=attendance.drop(['Count'],axis=1) 139 | attendance_final 140 | attendance_final.to_csv("/assets/attendance.csv") 141 | -------------------------------------------------------------------------------- /main/py/capture.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | 4 | # In[ ]: 5 | 6 | 7 | import cv2 8 | import numpy as np 9 | import time 10 | import os 11 | curd = os.getcwd() 12 | print("in Python file now") 13 | 14 | f = open("py/helper.txt", "r") 15 | name = f.read() 16 | print(name) 17 | f.close() 18 | 19 | print("FILE READ COMPLETE") 20 | path = r"{}\assets\data\{}".format(curd,name) 21 | try: 22 | os.mkdir(path) 23 | except OSError: 24 | print ("Creation of the directory %s failed" % path) 25 | cap = cv2.VideoCapture(0) 26 | cap.set(cv2.CAP_PROP_FPS, 100) 27 | rat, frame = cap.read() 28 | 29 | count=0 30 | while count<10: 31 | 32 | rat, frame = cap.read() 33 | cv2.imwrite(r"{}\{}{}.jpg".format(path,name,count), frame) 34 | count+=1 35 | cv2.imshow('img',frame) 36 | if cv2.waitKey(1) & 0xFF == ord('q'): 37 | break 38 | time.sleep(1) 39 | 40 | 41 | cap.release() 42 | cv2.destroyAllWindows() 43 | 44 | -------------------------------------------------------------------------------- /main/py/helper.txt: -------------------------------------------------------------------------------- 1 | RA1711003010488 -------------------------------------------------------------------------------- /main/py/phoneCapture.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | 4 | # In[ ]: 5 | 6 | 7 | import math 8 | import cv2 9 | import time 10 | from sklearn import neighbors 11 | import numpy as np 12 | import pandas as pd 13 | import os 14 | import os.path 15 | import pickle 16 | from PIL import Image, ImageDraw 17 | import face_recognition 18 | import requests 19 | from face_recognition.face_recognition_cli import image_files_in_folder 20 | curd = os.getcwd() 21 | 22 | try: 23 | os.mkdir("{}/models".format(curd)) 24 | except: 25 | pass 26 | names=[] 27 | ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg'} 28 | 29 | 30 | # In[ ]: 31 | 32 | 33 | with open('py/url.txt', 'r') as file: 34 | liveurl = file.read().replace('\n', '') 35 | url = "{}".format(liveurl) 36 | print(liveurl) 37 | 38 | count=0 39 | while count<10: 40 | curtime = time.strftime("%Y_%m_%d-%H_%M_%S") 41 | img_resp = requests.get(url) 42 | img_arr = np.array(bytearray(img_resp.content),dtype = np.uint8) 43 | frame = cv2.imdecode(img_arr,-1) 44 | cv2.imwrite("{}/test/{}.jpg".format(curd,curtime), frame) 45 | count+=1 46 | cv2.imshow('img',frame) 47 | if cv2.waitKey(1) & 0xFF == ord('q'): 48 | break 49 | time.sleep(3) 50 | 51 | 52 | cap.release() 53 | cv2.destroyAllWindows() 54 | 55 | 56 | # In[ ]: 57 | 58 | 59 | def predict(frame, knn_clf=None, model_path=None, distance_threshold=0.6): 60 | 61 | 62 | if knn_clf is None and model_path is None: 63 | raise Exception("Must supply knn classifier either thourgh knn_clf or model_path") 64 | 65 | if knn_clf is None: 66 | with open(model_path, 'rb') as f: 67 | knn_clf = pickle.load(f) 68 | 69 | 70 | # X_img = face_recognition.load_image_file(X_img_path) 71 | X_img = frame 72 | X_face_locations = face_recognition.face_locations(X_img) 73 | 74 | if len(X_face_locations) == 0: 75 | return [] 76 | 77 | faces_encodings = face_recognition.face_encodings(X_img, known_face_locations=X_face_locations) 78 | 79 | closest_distances = knn_clf.kneighbors(faces_encodings, n_neighbors=1) 80 | are_matches = [closest_distances[0][i][0] <= distance_threshold for i in range(len(X_face_locations))] 81 | 82 | return [(pred, loc) if rec else ("unknown", loc) for pred, loc, rec in zip(knn_clf.predict(faces_encodings), X_face_locations, are_matches)] 83 | 84 | 85 | # In[ ]: 86 | 87 | 88 | def show_prediction_labels_on_image(frame, predictions): 89 | 90 | #pil_image = Image.open(img_path).convert("RGB") 91 | pil_image = Image.fromarray(frame).convert("RGB") 92 | draw = ImageDraw.Draw(pil_image) 93 | 94 | for name, (top, right, bottom, left) in predictions: 95 | draw.rectangle(((left, top), (right, bottom)), outline=(0, 0, 255)) 96 | 97 | 98 | name = name.encode("UTF-8") 99 | 100 | text_width, text_height = draw.textsize(name) 101 | draw.rectangle(((left, bottom - text_height - 10), (right, bottom)), fill=(0, 0, 255), outline=(0, 0, 255)) 102 | draw.text((left + 6, bottom - text_height - 5), name, fill=(255, 255, 255, 255)) 103 | 104 | del draw 105 | 106 | #pil_image.show() 107 | #cv2.imshow("frame",pil_image) 108 | return np.asarray(pil_image) 109 | 110 | 111 | # In[ ]: 112 | 113 | 114 | for image_file in os.listdir(r"{}\test".format(curd)): 115 | full_file_path = os.path.join(r"{}\test".format(curd), image_file) 116 | 117 | print("Looking for faces in {}".format(image_file)) 118 | frame = cv2.imread(full_file_path,-1) 119 | 120 | predictions = predict(frame, model_path=r"{}\models\trained_knn_model.clf".format(curd)) 121 | 122 | for name, (top, right, bottom, left) in predictions: 123 | print("- Found {} at ({}, {})".format(name, left, top)) 124 | names.append(name) 125 | # Display results overlaid on an image 126 | #show_prediction_labels_on_image(frame, predictions) 127 | final_img = show_prediction_labels_on_image(frame, predictions) 128 | cv2.imshow("X",final_img) 129 | cv2.waitKey(0) 130 | cv2.destroyAllWindows() 131 | 132 | 133 | # In[ ]: 134 | 135 | 136 | namesD=pd.DataFrame(names, columns=["Names"]) 137 | namesD= namesD[namesD.Names!="unknown"] 138 | 139 | attendance= pd.DataFrame(namesD.iloc[:,0].value_counts()) 140 | attendance.rename(index=str,columns={'Names': 'Count'},inplace=True) 141 | attendance["Present"] =0 142 | 143 | attendance["Count"][0] > 5 144 | for i in range(attendance.shape[0]): 145 | if(attendance["Count"][i] > 5): 146 | attendance["Present"][i] =1 147 | 148 | 149 | attendance_final=attendance.drop(['Count'],axis=1) 150 | attendance_final 151 | attendance_final.to_csv('Attendance.csv') 152 | 153 | -------------------------------------------------------------------------------- /main/py/train.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | 4 | # In[1]: 5 | 6 | 7 | import math 8 | import cv2 9 | from sklearn import neighbors 10 | import numpy as np 11 | import pandas as pd 12 | import os 13 | import os.path 14 | import pickle 15 | from PIL import Image, ImageDraw 16 | import face_recognition 17 | from face_recognition.face_recognition_cli import image_files_in_folder 18 | print("in train") 19 | curd = os.getcwd() 20 | try: 21 | os.mkdir("{}/assets/models".format(curd)) 22 | except: 23 | pass 24 | ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg'} 25 | 26 | 27 | # In[ ]: 28 | 29 | 30 | def train(train_dir, model_save_path=None, n_neighbors=None, knn_algo='ball_tree', verbose=False): 31 | 32 | X = [] 33 | y = [] 34 | 35 | for class_dir in os.listdir(train_dir): 36 | if not os.path.isdir(os.path.join(train_dir, class_dir)): 37 | continue 38 | 39 | for img_path in image_files_in_folder(os.path.join(train_dir, class_dir)): 40 | image = face_recognition.load_image_file(img_path) 41 | face_bounding_boxes = face_recognition.face_locations(image) 42 | 43 | if len(face_bounding_boxes) != 1: 44 | if verbose: 45 | print("Image {} not suitable for training: {}".format(img_path, "Didn't find a face" if len(face_bounding_boxes) < 1 else "Found more than one face")) 46 | else: 47 | X.append(face_recognition.face_encodings(image, known_face_locations=face_bounding_boxes)[0]) 48 | y.append(class_dir) 49 | 50 | if n_neighbors is None: 51 | n_neighbors = int(round(math.sqrt(len(X)))) 52 | if verbose: 53 | print("Chose n_neighbors automatically:", n_neighbors) 54 | 55 | knn_clf = neighbors.KNeighborsClassifier(n_neighbors=n_neighbors, algorithm=knn_algo, weights='distance') 56 | knn_clf.fit(X, y) 57 | 58 | if model_save_path is not None: 59 | with open(model_save_path, 'wb') as f: 60 | pickle.dump(knn_clf, f) 61 | 62 | return knn_clf 63 | 64 | 65 | # In[ ]: 66 | 67 | 68 | #Trainer 69 | if __name__ == "__main__": 70 | # STEP 1: Train the KNN classifier and save it to disk 71 | print("Training KNN classifier...") 72 | classifier = train("assets/data", 73 | model_save_path="{}/assets/models/trained_knn_model.clf".format(curd), 74 | n_neighbors=2) 75 | print("Training complete!") 76 | 77 | --------------------------------------------------------------------------------