Skip to content

Commit c01e6ff

Browse files
reinitialzing library for computer vision essesntials
1 parent 2d5fe76 commit c01e6ff

26 files changed

+150
-9
lines changed
File renamed without changes.

08. Object Detection/README.md

Whitespace-only changes.
+9-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
""" Common object detection using CvLib and yolo3 """
2+
13
import cv2
24
import matplotlib.pyplot as plt
35
import cvlib as cv
46
from cvlib.object_detection import draw_bbox
57

6-
im = cv2.imread('apple.jpeg')
7-
bbox, label, conf = cv.detect_common_objects(im)
8+
img = cv2.imread('./Media/apple.jpeg')
9+
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
10+
11+
bbox, label, conf = cv.detect_common_objects(gray)
12+
813
output_image = draw_bbox(im, bbox, label, conf)
14+
915
plt.imshow(output_image)
10-
plt.savefig("apple-detected.jpeg")
16+
plt.savefig("./Media/apple-detected.jpeg")
1117
plt.show()
File renamed without changes.
File renamed without changes.

21. Facial Recognition/FaceRec.py

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import os
2+
import face_recognition
3+
import cv2
4+
import numpy as np
5+
6+
video_capture = cv2.VideoCapture(0)
7+
8+
9+
# Create arrays of known face encodings and their names
10+
known_face_encodings = []
11+
known_face_names = []
12+
13+
root_dir = os.path.dirname(os.path.abspath(os.path.abspath(__file__)))
14+
image_dir = os.path.join(root_dir, "images")
15+
16+
for file in os.listdir(image_dir):
17+
if file.endswith == ".jpeg" or ".jpg":
18+
input_face_name = file.split('.')[0]
19+
input_face = face_recognition.load_image_file(os.path.join(image_dir, file))
20+
input_face_encoding = face_recognition.face_encodings(input_face)[0]
21+
known_face_names.append(input_face_name)
22+
known_face_encodings.append(input_face_encoding)
23+
24+
# Initialize some variables
25+
face_locations = []
26+
face_encodings = []
27+
face_names = []
28+
process_this_frame = True
29+
30+
while True:
31+
# Grab a single frame of video
32+
ret, frame = video_capture.read()
33+
34+
# Resize frame of video to 1/4 size for faster face recognition processing
35+
small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)
36+
37+
# Convert the image from BGR color (which OpenCV uses) to RGB color (which face_recognition uses)
38+
rgb_small_frame = small_frame[:, :, ::-1]
39+
40+
# Only process every other frame of video to save time
41+
if process_this_frame:
42+
# Find all the faces and face encodings in the current frame of video
43+
face_locations = face_recognition.face_locations(rgb_small_frame)
44+
face_encodings = face_recognition.face_encodings(rgb_small_frame, face_locations)
45+
46+
face_names = []
47+
for face_encoding in face_encodings:
48+
# See if the face is a match for the known face(s)
49+
matches = face_recognition.compare_faces(known_face_encodings, face_encoding)
50+
name = "Unknown"
51+
52+
# # If a match was found in known_face_encodings, just use the first one.
53+
# if True in matches:
54+
# first_match_index = matches.index(True)
55+
# name = known_face_names[first_match_index]
56+
57+
# Or instead, use the known face with the smallest distance to the new face
58+
face_distances = face_recognition.face_distance(known_face_encodings, face_encoding)
59+
best_match_index = np.argmin(face_distances)
60+
if matches[best_match_index]:
61+
name = known_face_names[best_match_index]
62+
63+
face_names.append(name)
64+
process_this_frame = not process_this_frame
65+
66+
67+
# Display the results
68+
for (top, right, bottom, left), name in zip(face_locations, face_names):
69+
# Scale back up face locations since the frame we detected in was scaled to 1/4 size
70+
top *= 4
71+
right *= 4
72+
bottom *= 4
73+
left *= 4
74+
75+
# Draw a box around the face
76+
cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)
77+
78+
# Draw a label with a name below the face
79+
cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (0, 0, 255), cv2.FILLED)
80+
font = cv2.FONT_HERSHEY_DUPLEX
81+
cv2.putText(frame, name, (left + 6, bottom - 6), font, 1.0, (255, 255, 255), 1)
82+
83+
# Display the resulting image
84+
cv2.imshow('Video', frame)
85+
86+
# Hit 'q' on the keyboard to quit!
87+
if cv2.waitKey(1) & 0xFF == ord('q'):
88+
break
89+
90+
# Release handle to the webcam
91+
video_capture.release()
92+
cv2.destroyAllWindows()

21. Facial Recognition/README.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## Usgaes
2+
3+
1. Add Your Image in `Images` folder. exmaple >> name.jpeg
4+
5+
2. Install the requirements file
6+
7+
```bash
8+
python -m pip install -r requirements.txt
9+
```
10+
11+
3. Run the Script
12+
13+
```bash
14+
python FaceRec.py
15+
```
16+
17+
NOTE:- incase installtation stuck on dlib
18+
19+
```bash
20+
python -m pip install dlib -vvv
21+
```
273 KB
Loading

README.md

+28-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
# OpenCv Tutorial
1+
# Computer Vision Essentials
22

3-
<img align="right" src="Media/opencv-logo-white.png">
4-
5-
- [OpenCv Tutorial](#opencv-tutorial)
3+
- [Computer Vision Essentials](#computer-vision-essentials)
64
- [Introduction](#introduction)
5+
- [Used Libraries/Packages](#used-librariespackages)
76
- [How To Run](#how-to-run)
87
- [Usage](#usage)
98
- [Support](#support)
@@ -16,19 +15,42 @@
1615

1716
## Introduction
1817

19-
OpenCV is a cross-platform library using which we can develop real-time computer vision applications. It mainly focuses on image processing, video capture and analysis including features like face detection and object detection. In this tutorial, we explain how you can use OpenCV in your applications.
18+
According to [wikipedia](https://en.wikipedia.org/wiki/Computer_vision, "computer_vision-Wikipedia") -
19+
20+
Computer vision is an interdisciplinary scientific field that deals with how computers can gain high-level understanding from digital images or videos. From the perspective of engineering, it seeks to understand and automate tasks that the human visual system can do.
21+
22+
Computer vision tasks include methods for acquiring, processing, analyzing and understanding digital images, and extraction of high-dimensional data from the real world in order to produce numerical or symbolic information, e.g. in the forms of decisions.
23+
24+
[Read More ...](https://en.wikipedia.org/wiki/Computer_vision, "computer_vision-Wikipedia")
25+
26+
## Used Libraries/Packages
27+
28+
- **OpenCV** - OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library.
29+
- **CVLib** - A simple, high level, easy-to-use open source Computer Vision library for Python.
30+
- **Dlib** - Dlib is a general purpose cross-platform software library written in the programming language C++.
31+
- **PIL/Pillow** - Python Imaging Library is a free and open-source additional library for the Python programming language that adds support for opening, manipulating, and saving many different image file formats
32+
- **Keras** - Keras is the most used deep learning framework among top-5 winning teams on Kaggle.
33+
- **Tensorflow** - TensorFlow is a free and open-source software library for machine learning.
34+
- **Pytessarct** - Python-tesseract is an optical character recognition (OCR) tool for python. That is, it will recognize and “read” the text embedded in images.
35+
- **IPSDK** - IPSDK offers a comprehensive and optimized range of functionalities for 2D and 3D image processing.
36+
- **scikit-image** - scikit-image is an open-source image processing library for the Python programming language. It includes algorithms for segmentation, geometric transformations, color space manipulation, analysis, filtering, morphology, feature detection, and more.
37+
- **Matplotlib** - Matplotlib is a cross-platform, data visualization and graphical plotting library for Python and its numerical extension NumPy.
38+
- **mahotas** - Mahotas is a computer vision and image processing library for Python.
2039

2140
## How To Run
2241

2342
- Install python 3.6+
2443

2544
Create virtual envionment with `pipenv`.
45+
2646
```bash
2747
python -m pip install pipenv
2848
pipenv install -r requirements.txt
2949
pipenv shell
3050
```
3151

52+
NOTE- check the [guide](https://www.tensorflow.org/install) for tenosflow installation for your CPU/GPU. for using tensorflow-gpu install the CUDA-11.0 and necessary libraries.
53+
3254
## Usage
3355

3456
Computer vision allows the computer to perform the same kind of tasks as humans with the same efficiency. There are a two main task which are defined below:
@@ -75,7 +97,7 @@ For open source projects,Under MIT License.
7597

7698
## Author
7799

78-
- Project : OpenCv Tutorial
100+
- Project : Computer Vision Essentials
79101
- Language : Python
80102
- Github : <https://github.com/codePerfectPlus>
81103
- Website : <http://codeperfectplus.herokuapp.com>

requirements.txt

-271 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)