Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-208
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2021-208
2021-208
Commits
64a584d0
Commit
64a584d0
authored
Oct 11, 2021
by
dewmalFernando
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
V1.17
parent
5a2bf325
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
503 additions
and
241 deletions
+503
-241
UI/app.js
UI/app.js
+6
-4
abnormal_behavior_detection/HumanDetection/Human_Detection_Video.py
...ehavior_detection/HumanDetection/Human_Detection_Video.py
+1
-0
app.py
app.py
+211
-186
imageEnhancement/ContrastEdjustments.py
imageEnhancement/ContrastEdjustments.py
+41
-0
imageEnhancement/CreateNewFolderForFrames.py
imageEnhancement/CreateNewFolderForFrames.py
+143
-9
imageEnhancement/CreateNewFolderForVideos.py
imageEnhancement/CreateNewFolderForVideos.py
+6
-15
imageEnhancement/EnhaceFramesUsingUnsharpMasking.py
imageEnhancement/EnhaceFramesUsingUnsharpMasking.py
+0
-5
imageEnhancement/FramesToVid.py
imageEnhancement/FramesToVid.py
+15
-22
imageEnhancement/ImageSharpening.py
imageEnhancement/ImageSharpening.py
+30
-0
imageEnhancement/RemoveGaussianNoise.py
imageEnhancement/RemoveGaussianNoise.py
+26
-0
imageEnhancement/Smooth.py
imageEnhancement/Smooth.py
+24
-0
No files found.
UI/app.js
View file @
64a584d0
...
@@ -33,12 +33,14 @@ if(result != null){
...
@@ -33,12 +33,14 @@ if(result != null){
<!-- <p>Your account details are below:</p> -->
<!-- <p>Your account details are below:</p> -->
<table >
<table >
<tr >
<tr >
<td>
Enhancement type :
</td>
<td>
Contrast Adjustment : Clahe
</td>
</tr>
</tr>
<tr>
<tr>
<td>Method Type :</td>
<td>Improve Image Shapness : Unsharp masking</td>
</tr>
<tr>
<td>Noise Type : Gaussian noise</td>
</tr>
</tr>
</table>
</table>
</div>
</div>
</div>
</div>
...
@@ -247,7 +249,7 @@ function insertVideoAbnormal(newVideo) {
...
@@ -247,7 +249,7 @@ function insertVideoAbnormal(newVideo) {
console
.
log
(
data
)
console
.
log
(
data
)
console
.
log
(
data
.
id
)
console
.
log
(
data
.
id
)
data
.
path
=
"
E:
\\
BACKBONE
\\
videos
\\
Input.mp4
"
//
data.path = "E:\\BACKBONE\\videos\\Input.mp4"
let
id
=
data
.
id
let
id
=
data
.
id
fetch
(
`http://127.0.0.1:5000/startAbnormalBehaviourDetection`
,
{
fetch
(
`http://127.0.0.1:5000/startAbnormalBehaviourDetection`
,
{
...
...
abnormal_behavior_detection/HumanDetection/Human_Detection_Video.py
View file @
64a584d0
...
@@ -10,6 +10,7 @@ from tifffile import askopenfilename
...
@@ -10,6 +10,7 @@ from tifffile import askopenfilename
def
capture_humans
(
path
):
def
capture_humans
(
path
):
# path = "E:\\BACKBONE\\videos\\Input.mp4"
print
(
path
)
print
(
path
)
protopath
=
"E:/BACKBONE/abnormal_behavior_detection/Models/Human Detection/MobileNetSSD_deploy.prototxt"
protopath
=
"E:/BACKBONE/abnormal_behavior_detection/Models/Human Detection/MobileNetSSD_deploy.prototxt"
...
...
app.py
View file @
64a584d0
...
@@ -38,111 +38,6 @@ video_files = VideoSchema(many=True)
...
@@ -38,111 +38,6 @@ video_files = VideoSchema(many=True)
value_field
=
Values
()
value_field
=
Values
()
class
EnhancedVideos
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
name
=
db
.
Column
(
db
.
String
(
50
))
path
=
db
.
Column
(
db
.
String
(
150
))
def
__init__
(
self
,
name
,
path
):
self
.
name
=
name
self
.
path
=
path
class
EnhancedVideosSchema
(
ma
.
Schema
):
class
Meta
:
fields
=
(
'id'
,
'name'
,
'path'
)
class
EnhancedValues
:
class
Meta
:
fields
=
'value'
EnhancedVideoFile
=
EnhancedVideosSchema
()
EnhancedVideo_value_field
=
EnhancedValues
()
class
AbnormalBehaviourDetails
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
typeOfAttack
=
db
.
Column
(
db
.
String
(
100
))
usedWeapon
=
db
.
Column
(
db
.
String
(
100
))
def
__init__
(
self
,
typeOfAttack
,
usedWeapon
):
self
.
usedWeapon
=
usedWeapon
self
.
typeOfAttack
=
typeOfAttack
class
AbnormalBehaviourSchema
(
ma
.
Schema
):
class
Meta
:
fields
=
(
'id'
,
'usedWeapon'
,
'typeOfAttack'
)
class
Values
:
class
Meta
:
fields
=
'value'
AbnormalBehaviour
=
AbnormalBehaviourSchema
()
AbnormalBehaviours
=
AbnormalBehaviourSchema
(
many
=
True
)
AbnormalBehaviour_value_field
=
Values
()
# For Face Recognition
class
FaceRecognitionDetails
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
name
=
db
.
Column
(
db
.
String
(
100
))
path
=
db
.
Column
(
db
.
String
(
250
))
def
__init__
(
self
,
name
,
path
):
self
.
name
=
name
self
.
path
=
path
class
FaceRecognitionSchema
(
ma
.
Schema
):
class
Meta
:
fields
=
(
'id'
,
'name'
,
'path'
)
class
Values
:
class
Meta
:
fields
=
'value'
faceRecognitionSchema
=
FaceRecognitionSchema
()
faceRecognitionSchemas
=
FaceRecognitionSchema
(
many
=
True
)
FaceRecognitionSchema_field
=
Values
()
# Figure
class
FigureDetails
(
db
.
Model
):
# Articles
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
age
=
db
.
Column
(
db
.
String
(
20
))
gender
=
db
.
Column
(
db
.
String
(
6
))
height
=
db
.
Column
(
db
.
Float
())
def
__init__
(
self
,
age
,
gender
,
height
):
self
.
age
=
age
self
.
gender
=
gender
self
.
height
=
height
class
FigureSchema
(
ma
.
Schema
):
class
Meta
:
fields
=
(
'id'
,
'age'
,
'gender'
,
'height'
)
class
Values
():
class
Meta
:
fields
=
'value'
figure_data
=
FigureSchema
()
figure_datas
=
FigureSchema
(
many
=
True
)
@
app
.
route
(
'/get'
,
methods
=
[
'GET'
])
@
app
.
route
(
'/get'
,
methods
=
[
'GET'
])
def
get_videos
():
def
get_videos
():
videos
=
VideoDetails
.
query
.
all
()
videos
=
VideoDetails
.
query
.
all
()
...
@@ -178,6 +73,34 @@ def add_video():
...
@@ -178,6 +73,34 @@ def add_video():
return
video_file
.
jsonify
(
video
)
return
video_file
.
jsonify
(
video
)
""" Start of the image enhancement function """
class
EnhancedVideos
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
name
=
db
.
Column
(
db
.
String
(
50
))
path
=
db
.
Column
(
db
.
String
(
150
))
def
__init__
(
self
,
name
,
path
):
self
.
name
=
name
self
.
path
=
path
class
EnhancedVideosSchema
(
ma
.
Schema
):
class
Meta
:
fields
=
(
'id'
,
'name'
,
'path'
)
class
EnhancedValues
:
class
Meta
:
fields
=
'value'
EnhancedVideoFile
=
EnhancedVideosSchema
()
EnhancedVideo_value_field
=
EnhancedValues
()
@
app
.
route
(
'/StartImageEnhance'
,
methods
=
[
'POST'
])
@
app
.
route
(
'/StartImageEnhance'
,
methods
=
[
'POST'
])
def
StartImageEnhance
():
def
StartImageEnhance
():
from
imageEnhancement
import
VidToFrames
from
imageEnhancement
import
VidToFrames
...
@@ -199,6 +122,37 @@ def StartImageEnhance():
...
@@ -199,6 +122,37 @@ def StartImageEnhance():
return
values
return
values
""" End of the image enhancement function """
""" Start of the abnormal behavior detection function """
class
AbnormalBehaviourDetails
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
typeOfAttack
=
db
.
Column
(
db
.
String
(
100
))
usedWeapon
=
db
.
Column
(
db
.
String
(
100
))
def
__init__
(
self
,
typeOfAttack
,
usedWeapon
):
self
.
usedWeapon
=
usedWeapon
self
.
typeOfAttack
=
typeOfAttack
class
AbnormalBehaviourSchema
(
ma
.
Schema
):
class
Meta
:
fields
=
(
'id'
,
'usedWeapon'
,
'typeOfAttack'
)
class
Values
:
class
Meta
:
fields
=
'value'
AbnormalBehaviour
=
AbnormalBehaviourSchema
()
AbnormalBehaviours
=
AbnormalBehaviourSchema
(
many
=
True
)
AbnormalBehaviour_value_field
=
Values
()
@
app
.
route
(
'/startAbnormalBehaviourDetection'
,
methods
=
[
'POST'
])
@
app
.
route
(
'/startAbnormalBehaviourDetection'
,
methods
=
[
'POST'
])
def
startAbnormalBehaviourDetection
():
def
startAbnormalBehaviourDetection
():
from
abnormal_behavior_detection.ScriptsOrder
import
Scripts_Order
from
abnormal_behavior_detection.ScriptsOrder
import
Scripts_Order
...
@@ -214,85 +168,78 @@ def startAbnormalBehaviourDetection():
...
@@ -214,85 +168,78 @@ def startAbnormalBehaviourDetection():
# data = {'id': id, 'name': name, 'path': path}
# data = {'id': id, 'name': name, 'path': path}
# Human_Detection_Video.capture_humans('C:/Users/Givindu/Desktop/New folder/'+path[2])
# Human_Detection_Video.capture_humans('C:/Users/Givindu/Desktop/New folder/'+path[2])
AbDetection
=
Scripts_Order
.
data
(
path
)
print
(
"app -> "
+
path
)
AbDetection
=
Scripts_Order
.
data
(
"E:
\\
BACKBONE
\\
image_enhancement
\\
EnhancedVideos
\\
EnhancedVideo1
\\
"
+
path
.
split
(
"
\\
"
)[
2
])
return
jsonify
(
AbDetection
)
return
jsonify
(
AbDetection
)
@
app
.
route
(
'/RunFaceRecognition/<id>/'
,
methods
=
[
'POST'
])
class
behavior_details
(
db
.
Model
):
def
RunFaceRecognition
(
id
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
from
face_detection_recognition
import
script_file
incident_type
=
db
.
Column
(
db
.
String
(
100
))
id
=
request
.
json
[
'id'
]
used_weapon
=
db
.
Column
(
db
.
String
(
100
))
name
=
request
.
json
[
'name'
]
detected_time
=
db
.
Column
(
db
.
Float
())
path
=
request
.
json
[
'path'
]
# data = get_video(id)
path
=
str
(
path
)
.
split
(
'
\\
'
)
def
__init__
(
self
,
incident_type
,
used_weapon
,
detected_time
):
print
(
path
)
self
.
incident_type
=
incident_type
self
.
used_weapon
=
used_weapon
self
.
detected_time
=
detected_time
data
=
{
'id'
:
id
,
'name'
:
name
,
'path'
:
path
}
# data = {'id': id, 'name': name, 'path': path}
# FaceRecognition = Scripts.data('C:/Users/Praveen/Desktop/Research project/PP1 input/Input video/' + path[2])
class
behavior_details_schema
(
ma
.
Schema
):
FDRecognition
=
script_file
.
data
(
'E:
\\
BACKBONE
\\
videos
\\
'
+
path
[
2
])
class
Meta
:
fields
=
(
'id'
,
'incident_type'
,
'used_weapon'
,
'detected_time'
)
return
jsonify
(
FDRecognition
)
behaviors_schema
=
behavior_details_schema
()
behaviors_schema
=
behavior_details_schema
(
many
=
True
)
@
app
.
route
(
'/StartFaceRecognition'
,
methods
=
[
'POST'
])
def
StartFaceRecognition
():
from
face_detection_recognition
import
script_file
# path = request.json['path']
class
criminal_result_schema
(
ma
.
Schema
):
# # data = get_video(id)
class
Meta
:
#
fields
=
(
# path = str(path).split('\\')
'id'
,
'incident_type'
,
'used_weapon'
,
'detected_time'
)
# print(path)
# FaceRecognition = Scripts.data('C:/Users/Praveen/Desktop/Research project/PP1 input/Input video/' + path[2])
FDRecognition
=
script_file
.
imagetovideo_process
(
'E:/BACKBONE/abnormal_behavior_detection/frames/Suspects with Weapons/'
)
return
jsonify
(
FDRecognition
)
criminal_schema
=
criminal_result_schema
()
criminals_schema
=
criminal_result_schema
(
many
=
True
)
""" End of the abnormal behavior detection function """
@
app
.
route
(
'/RunFigureRecognition'
,
methods
=
[
'POST'
])
""" Start of the face recognition function """
def
RunFigureRecognition
():
from
figure_recognition.ScriptList
import
Script_List
path
=
request
.
json
[
'path'
]
# data = get_video(id)
path
=
str
(
path
)
.
split
(
'
\\
'
)
print
(
path
)
# data = {'id': id, 'name': name, 'path': path}
# data = {'id': id, 'name': name, 'path': path}
age
,
gender
=
Script_List
.
data
(
'C:/Users/USER/Desktop/Research/image/'
+
path
[
2
])
# figure_data.jsonify({'id':0, 'age':age, 'gender':gender, 'height':0})
# For Face Recognition
return
jsonify
(
age
,
gender
)
class
FaceRecognitionDetails
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
name
=
db
.
Column
(
db
.
String
(
100
))
path
=
db
.
Column
(
db
.
String
(
250
))
def
__init__
(
self
,
name
,
path
):
self
.
name
=
name
self
.
path
=
path
@
app
.
route
(
'/StartFigureRecognition'
,
methods
=
[
'GET'
])
class
FaceRecognitionSchema
(
ma
.
Schema
):
def
StartFigureRecognition
()
:
class
Meta
:
from
figure_recognition.ScriptList
import
Script_List
fields
=
(
'id'
,
'name'
,
'path'
)
age
,
gender
=
Script_List
.
figure
()
# figure_data.jsonify({'id':0, 'age':age, 'gender':gender, 'height':0})
class
Values
:
return
jsonify
(
age
,
gender
)
class
Meta
:
fields
=
'value'
@
app
.
route
(
'/SaveFigureData'
,
methods
=
[
'POST'
])
faceRecognitionSchema
=
FaceRecognitionSchema
()
def
SaveFigureData
():
faceRecognitionSchemas
=
FaceRecognitionSchema
(
many
=
True
)
age
=
request
.
json
[
'age'
]
gender
=
request
.
json
[
'gender'
]
height
=
5.4
data
=
FigureDetails
(
age
,
gender
,
height
)
FaceRecognitionSchema_field
=
Values
()
db
.
session
.
add
(
data
)
db
.
session
.
commit
()
return
jsonify
(
"Done"
);
""" End of the abnormal behavior detection function """
""" Start of the face detection function """
# Criminals table input fields
# Criminals table input fields
...
@@ -405,28 +352,6 @@ def update_Criminals_details(id):
...
@@ -405,28 +352,6 @@ def update_Criminals_details(id):
return
criminals_Schema
.
jsonify
(
criminals_details
)
return
criminals_Schema
.
jsonify
(
criminals_details
)
class
behavior_details
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
incident_type
=
db
.
Column
(
db
.
String
(
100
))
used_weapon
=
db
.
Column
(
db
.
String
(
100
))
detected_time
=
db
.
Column
(
db
.
Float
())
def
__init__
(
self
,
incident_type
,
used_weapon
,
detected_time
):
self
.
incident_type
=
incident_type
self
.
used_weapon
=
used_weapon
self
.
detected_time
=
detected_time
class
behavior_details_schema
(
ma
.
Schema
):
class
Meta
:
fields
=
(
'id'
,
'incident_type'
,
'used_weapon'
,
'detected_time'
)
behaviors_schema
=
behavior_details_schema
()
behaviors_schema
=
behavior_details_schema
(
many
=
True
)
class
criminal_result
(
db
.
Model
):
class
criminal_result
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
Name
=
db
.
Column
(
db
.
String
(
100
))
Name
=
db
.
Column
(
db
.
String
(
100
))
...
@@ -451,14 +376,73 @@ class criminal_result(db.Model):
...
@@ -451,14 +376,73 @@ class criminal_result(db.Model):
self
.
Crimes
=
Crimes
self
.
Crimes
=
Crimes
class
criminal_result_schema
(
ma
.
Schema
):
@
app
.
route
(
'/RunFaceRecognition/<id>/'
,
methods
=
[
'POST'
])
def
RunFaceRecognition
(
id
):
from
face_detection_recognition
import
script_file
id
=
request
.
json
[
'id'
]
name
=
request
.
json
[
'name'
]
path
=
request
.
json
[
'path'
]
# data = get_video(id)
path
=
str
(
path
)
.
split
(
'
\\
'
)
print
(
path
)
data
=
{
'id'
:
id
,
'name'
:
name
,
'path'
:
path
}
# data = {'id': id, 'name': name, 'path': path}
# FaceRecognition = Scripts.data('C:/Users/Praveen/Desktop/Research project/PP1 input/Input video/' + path[2])
FDRecognition
=
script_file
.
data
(
'E:
\\
BACKBONE
\\
videos
\\
'
+
path
[
2
])
return
jsonify
(
FDRecognition
)
@
app
.
route
(
'/StartFaceRecognition'
,
methods
=
[
'POST'
])
def
StartFaceRecognition
():
from
face_detection_recognition
import
script_file
# path = request.json['path']
# # data = get_video(id)
#
# path = str(path).split('\\')
# print(path)
# FaceRecognition = Scripts.data('C:/Users/Praveen/Desktop/Research project/PP1 input/Input video/' + path[2])
FDRecognition
=
script_file
.
imagetovideo_process
(
'E:/BACKBONE/abnormal_behavior_detection/frames/Suspects with Weapons/'
)
return
jsonify
(
FDRecognition
)
""" End of the face detection function """
""" Start of the figure recognition function """
# Figure
class
FigureDetails
(
db
.
Model
):
# Articles
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
age
=
db
.
Column
(
db
.
String
(
20
))
gender
=
db
.
Column
(
db
.
String
(
6
))
height
=
db
.
Column
(
db
.
Float
())
def
__init__
(
self
,
age
,
gender
,
height
):
self
.
age
=
age
self
.
gender
=
gender
self
.
height
=
height
class
FigureSchema
(
ma
.
Schema
):
class
Meta
:
class
Meta
:
fields
=
(
fields
=
(
'id'
,
'age'
,
'gender'
,
'height'
)
'id'
,
'incident_type'
,
'used_weapon'
,
'detected_time'
)
criminal_schema
=
criminal_result_schema
()
class
Values
():
criminals_schema
=
criminal_result_schema
(
many
=
True
)
class
Meta
:
fields
=
'value'
figure_data
=
FigureSchema
()
figure_datas
=
FigureSchema
(
many
=
True
)
@
app
.
route
(
'/GetAllData'
,
methods
=
[
'GET'
])
@
app
.
route
(
'/GetAllData'
,
methods
=
[
'GET'
])
...
@@ -498,5 +482,46 @@ def GetAllData():
...
@@ -498,5 +482,46 @@ def GetAllData():
return
jsonify
(
data1
,
data2
,
data3
)
return
jsonify
(
data1
,
data2
,
data3
)
@
app
.
route
(
'/RunFigureRecognition'
,
methods
=
[
'POST'
])
def
RunFigureRecognition
():
from
figure_recognition.ScriptList
import
Script_List
path
=
request
.
json
[
'path'
]
# data = get_video(id)
path
=
str
(
path
)
.
split
(
'
\\
'
)
print
(
path
)
# data = {'id': id, 'name': name, 'path': path}
# data = {'id': id, 'name': name, 'path': path}
age
,
gender
=
Script_List
.
data
(
'C:/Users/USER/Desktop/Research/image/'
+
path
[
2
])
# figure_data.jsonify({'id':0, 'age':age, 'gender':gender, 'height':0})
return
jsonify
(
age
,
gender
)
@
app
.
route
(
'/StartFigureRecognition'
,
methods
=
[
'GET'
])
def
StartFigureRecognition
():
from
figure_recognition.ScriptList
import
Script_List
age
,
gender
=
Script_List
.
figure
()
# figure_data.jsonify({'id':0, 'age':age, 'gender':gender, 'height':0})
return
jsonify
(
age
,
gender
)
@
app
.
route
(
'/SaveFigureData'
,
methods
=
[
'POST'
])
def
SaveFigureData
():
age
=
request
.
json
[
'age'
]
gender
=
request
.
json
[
'gender'
]
height
=
5.4
data
=
FigureDetails
(
age
,
gender
,
height
)
db
.
session
.
add
(
data
)
db
.
session
.
commit
()
return
jsonify
(
"Done"
);
""" End of the figure recognition function """
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
app
.
run
(
debug
=
True
)
app
.
run
(
debug
=
True
)
imageEnhancement/ContrastEdjustments.py
0 → 100644
View file @
64a584d0
import
cv2
import
os
from
imageEnhancement
import
ImageSharpening
from
imageEnhancement
import
CreateNewFolderForFrames
def
adjustContrast
(
folder
,
rate
):
contrastAdjustedFrames
=
CreateNewFolderForFrames
.
createFolderForContrasted
(
folder
)
path
=
"E:
\\
BACKBONE
\\
image_enhancement
\\
Frames
\\
"
+
folder
count
=
10000000
for
file
in
os
.
listdir
(
path
):
if
file
.
endswith
(
".jpg"
):
# -----Reading the image-----------------------------------------------------
img
=
cv2
.
imread
(
path
+
"
\\
"
+
file
)
# -----Converting image to LAB Color model-----------------------------------
lab
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2LAB
)
# -----Splitting the LAB image to different channels-------------------------
l
,
a
,
b
=
cv2
.
split
(
lab
)
# -----Applying CLAHE to L-channel-------------------------------------------
clahe
=
cv2
.
createCLAHE
(
clipLimit
=
3.0
,
tileGridSize
=
(
5
,
5
))
cl
=
clahe
.
apply
(
l
)
# -----Merge the CLAHE enhanced L-channel with the a and b channel-----------
limg
=
cv2
.
merge
((
cl
,
a
,
b
))
# -----Converting image from LAB Color model to RGB model--------------------
final
=
cv2
.
cvtColor
(
limg
,
cv2
.
COLOR_LAB2BGR
)
cv2
.
imwrite
(
contrastAdjustedFrames
+
"
\\
%
d.jpg"
%
count
,
final
)
count
+=
1
value
=
ImageSharpening
.
imageSharp
(
folder
,
contrastAdjustedFrames
,
rate
)
return
value
imageEnhancement/CreateNewFolderForFrames.py
View file @
64a584d0
# Python program to explain os.mkdir() method
# importing os module
import
os
import
os
def
createFolder
():
def
createFolder
():
parentPath
=
"E:
\\
BACKBONE
\\
image_enhancement
\\
Frames"
parentPath
=
"E:
\\
BACKBONE
\\
image_enhancement
\\
Frames"
...
@@ -36,9 +34,10 @@ def createFolder():
...
@@ -36,9 +34,10 @@ def createFolder():
print
(
"Directory '
%
s' created"
%
directory
)
print
(
"Directory '
%
s' created"
%
directory
)
return
directory
return
directory
def
createFolderForEnhancedFrames
(
folderName
):
def
createFolderForEnhancedFrames
(
folderName
):
print
(
"folder name in createFolderForEnhancedFrames : "
+
folderName
)
print
(
"folder name in createFolderForEnhancedFrames : "
+
folderName
)
parentPath
=
"E:
\\
BACKBONE
\\
image_enhancement
\\
Frames
\\
"
+
folderName
parentPath
=
"E:
\\
BACKBONE
\\
image_enhancement
\\
Frames
\\
"
+
folderName
totalFiles
=
0
totalFiles
=
0
totalDir
=
0
totalDir
=
0
...
@@ -58,7 +57,7 @@ def createFolderForEnhancedFrames(folderName):
...
@@ -58,7 +57,7 @@ def createFolderForEnhancedFrames(folderName):
directory
=
"Enhanced_Frames"
+
str
(
count
)
directory
=
"Enhanced_Frames"
+
str
(
count
)
# Parent Directory path
# Parent Directory path
parent_dir
=
"E:
\\
BACKBONE
\\
image_enhancement
\\
Frames
\\
"
+
folderName
parent_dir
=
"E:
\\
BACKBONE
\\
image_enhancement
\\
Frames
\\
"
+
folderName
# Path
# Path
path
=
os
.
path
.
join
(
parent_dir
,
directory
)
path
=
os
.
path
.
join
(
parent_dir
,
directory
)
...
@@ -71,7 +70,142 @@ def createFolderForEnhancedFrames(folderName):
...
@@ -71,7 +70,142 @@ def createFolderForEnhancedFrames(folderName):
print
(
"Directory '
%
s' created"
%
directory
)
print
(
"Directory '
%
s' created"
%
directory
)
return
directory
return
directory
# if __name__ == '__main__':
# # Calling the function
# createFolder()
def
createFolderForContrasted
(
folderName
):
parentPath
=
"E:
\\
BACKBONE
\\
image_enhancement
\\
Frames
\\
"
+
folderName
totalFiles
=
0
totalDir
=
0
for
base
,
dirs
,
files
in
os
.
walk
(
parentPath
):
print
(
'Searching in : '
,
base
)
for
directories
in
dirs
:
totalDir
+=
1
for
Files
in
files
:
totalFiles
+=
1
print
(
'Total Number of directories'
,
totalDir
)
count
=
totalDir
+
1
# Directory
directory
=
"Contrast_Adjusted_Frames"
+
str
(
count
)
# Parent Directory path
parent_dir
=
"E:
\\
BACKBONE
\\
image_enhancement
\\
Frames
\\
"
+
folderName
# Path
path
=
os
.
path
.
join
(
parent_dir
,
directory
)
# Create the directory
# 'GeeksForGeeks' in
# '/home / User / Documents'
os
.
mkdir
(
path
)
print
(
"path : "
+
path
)
print
(
"Directory '
%
s' created"
%
directory
)
return
path
def
createFolderForSharpImages
(
folderName
):
parentPath
=
"E:
\\
BACKBONE
\\
image_enhancement
\\
Frames
\\
"
+
folderName
totalFiles
=
0
totalDir
=
0
for
base
,
dirs
,
files
in
os
.
walk
(
parentPath
):
print
(
'Searching in : '
,
base
)
for
directories
in
dirs
:
totalDir
+=
1
for
Files
in
files
:
totalFiles
+=
1
print
(
'Total Number of directories'
,
totalDir
)
count
=
totalDir
+
1
# Directory
directory
=
"Sharp_Frames"
+
str
(
count
)
# Parent Directory path
parent_dir
=
"E:
\\
BACKBONE
\\
image_enhancement
\\
Frames
\\
"
+
folderName
# Path
path
=
os
.
path
.
join
(
parent_dir
,
directory
)
# Create the directory
# 'GeeksForGeeks' in
# '/home / User / Documents'
os
.
mkdir
(
path
)
print
(
"path : "
+
path
)
print
(
"Directory '
%
s' created"
%
directory
)
return
path
def
DenoiseGaussian
(
folderName
):
parentPath
=
"E:
\\
BACKBONE
\\
image_enhancement
\\
Frames
\\
"
+
folderName
totalFiles
=
0
totalDir
=
0
for
base
,
dirs
,
files
in
os
.
walk
(
parentPath
):
print
(
'Searching in : '
,
base
)
for
directories
in
dirs
:
totalDir
+=
1
for
Files
in
files
:
totalFiles
+=
1
print
(
'Total Number of directories'
,
totalDir
)
count
=
totalDir
+
1
# Directory
directory
=
"Gaussian_Denoised_Frames"
+
str
(
count
)
# Parent Directory path
parent_dir
=
"E:
\\
BACKBONE
\\
image_enhancement
\\
Frames
\\
"
+
folderName
# Path
path
=
os
.
path
.
join
(
parent_dir
,
directory
)
# Create the directory
# 'GeeksForGeeks' in
# '/home / User / Documents'
os
.
mkdir
(
path
)
print
(
"path : "
+
path
)
print
(
"Directory '
%
s' created"
%
directory
)
return
path
def
smoothImagesFolder
(
folderName
):
parentPath
=
"E:
\\
BACKBONE
\\
image_enhancement
\\
Frames
\\
"
+
folderName
totalFiles
=
0
totalDir
=
0
for
base
,
dirs
,
files
in
os
.
walk
(
parentPath
):
print
(
'Searching in : '
,
base
)
for
directories
in
dirs
:
totalDir
+=
1
for
Files
in
files
:
totalFiles
+=
1
print
(
'Total Number of directories'
,
totalDir
)
count
=
totalDir
+
1
# Directory
directory
=
"Smooth_Images"
+
str
(
count
)
# Parent Directory path
parent_dir
=
"E:
\\
BACKBONE
\\
image_enhancement
\\
Frames
\\
"
+
folderName
# Path
path
=
os
.
path
.
join
(
parent_dir
,
directory
)
# Create the directory
# 'GeeksForGeeks' in
# '/home / User / Documents'
os
.
mkdir
(
path
)
print
(
"path : "
+
path
)
print
(
"Directory '
%
s' created"
%
directory
)
return
path
imageEnhancement/CreateNewFolderForVideos.py
View file @
64a584d0
# Python program to explain os.mkdir() method
# importing os module
import
os
import
os
def
createFolder
(
name
):
def
createFolderForEnhancedVideos
():
parentPath
=
"E:
\\
BACKBONE
\\
image_enhancement
\\
EnhancedVideos"
parentPath
=
"E:
\\
BACKBONE
\\
image_enhancement
\\
EnhancedVideos"
totalFiles
=
0
totalFiles
=
0
...
@@ -21,22 +19,15 @@ def createFolder(name):
...
@@ -21,22 +19,15 @@ def createFolder(name):
count
=
totalDir
+
1
count
=
totalDir
+
1
# Directory
# Directory
directory
=
name
directory
=
"EnhancedVideo"
+
str
(
count
)
# Parent Directory path
parent_dir
=
"E:
\\
BACKBONE
\\
image_enhancement
\\
EnhancedVideos
\\
"
# Path
# Path
path
=
os
.
path
.
join
(
parent
_dir
,
directory
)
path
=
os
.
path
.
join
(
parent
Path
,
directory
)
# Create the directory
# Create the directory
# 'GeeksForGeeks' in
# 'GeeksForGeeks' in
# '/home / User / Documents'
# '/home / User / Documents'
os
.
mkdir
(
path
)
os
.
mkdir
(
path
)
print
(
"path : "
+
path
)
print
(
"Directory '
%
s' created"
%
directory
)
print
(
"Directory '
%
s' created"
%
directory
)
return
directory
return
path
if
__name__
==
'__main__'
:
# Calling the function
createFolder
()
imageEnhancement/EnhaceFramesUsingUnsharpMasking.py
View file @
64a584d0
import
cv2
as
cv2
import
cv2
as
cv2
import
numpy
as
np
import
os
import
os
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
...
@@ -20,13 +19,9 @@ def enhanceFrames(folderName, rate):
...
@@ -20,13 +19,9 @@ def enhanceFrames(folderName, rate):
for
file
in
os
.
listdir
(
path
):
for
file
in
os
.
listdir
(
path
):
if
file
.
endswith
(
".jpg"
):
if
file
.
endswith
(
".jpg"
):
image
=
cv2
.
imread
(
path
+
"
\\
"
+
file
)
image
=
cv2
.
imread
(
path
+
"
\\
"
+
file
)
# print(image)
# print("file : " + file)
gaussian_3
=
cv2
.
GaussianBlur
(
image
,
(
0
,
0
),
3.0
)
gaussian_3
=
cv2
.
GaussianBlur
(
image
,
(
0
,
0
),
3.0
)
unsharp_image
=
cv2
.
addWeighted
(
image
,
5
,
gaussian_3
,
-
3.5
,
0
,
image
)
unsharp_image
=
cv2
.
addWeighted
(
image
,
5
,
gaussian_3
,
-
3.5
,
0
,
image
)
cv2
.
imwrite
(
"E:
\\
BACKBONE
\\
image_enhancement
\\
Frames
\\
"
+
folderName
+
"
\\
"
+
enhancedPath
+
"
\\
%
d.jpg"
%
count
,
unsharp_image
)
cv2
.
imwrite
(
"E:
\\
BACKBONE
\\
image_enhancement
\\
Frames
\\
"
+
folderName
+
"
\\
"
+
enhancedPath
+
"
\\
%
d.jpg"
%
count
,
unsharp_image
)
# cv2.waitKey(0)
# cv2.destroyAllWindows()
count
+=
1
count
+=
1
value
=
FramesToVid
.
generate_video
(
folderName
,
enhancedPath
,
rate
)
value
=
FramesToVid
.
generate_video
(
folderName
,
enhancedPath
,
rate
)
...
...
imageEnhancement/FramesToVid.py
View file @
64a584d0
...
@@ -3,25 +3,19 @@ import os
...
@@ -3,25 +3,19 @@ import os
import
cv2
import
cv2
from
PIL
import
Image
from
PIL
import
Image
# Video Generating function
# Video Generating function
from
imageEnhancement
import
CreateNewFolderForVideos
from
imageEnhancement
import
CreateNewFolderForVideos
def
generate_video
(
folderName
,
enhancedPath
,
rate
):
def
generate_video
(
folderName
,
parentFolder
,
rate
):
print
(
"folder name : "
+
folderName
)
print
(
"Image folder : "
+
folderName
)
print
(
"enhancedPath : "
+
enhancedPath
)
print
(
"parentFolder : "
+
parentFolder
)
video_folder_name
=
"video_"
+
folderName
video_folder_name
=
"video_"
+
folderName
.
split
(
'
\\
'
)[
5
]
CreateNewFolderForVideos
.
createFolder
(
video_folder_name
)
# Checking the current directory path
video_folder_path
=
CreateNewFolderForVideos
.
createFolderForEnhancedVideos
()
#print(os.getcwd())
# Folder which contains all the images
# path = "E:\\BACKBONE\\image_enhancement\\Frames\\"+folderName+"\\"+enhancedPath
# from which video is to be generated
path
=
folderName
#os.chdir("E:\\#ProgrammingWork\\Python\\VideoEnhance\\Frames\\"+folderName)
path
=
"E:
\\
BACKBONE
\\
image_enhancement
\\
Frames
\\
"
+
folderName
+
"
\\
"
+
enhancedPath
mean_height
=
0
mean_height
=
0
mean_width
=
0
mean_width
=
0
...
@@ -44,9 +38,6 @@ def generate_video(folderName, enhancedPath, rate):
...
@@ -44,9 +38,6 @@ def generate_video(folderName, enhancedPath, rate):
mean_width
=
int
(
mean_width
/
num_of_images
)
mean_width
=
int
(
mean_width
/
num_of_images
)
mean_height
=
int
(
mean_height
/
num_of_images
)
mean_height
=
int
(
mean_height
/
num_of_images
)
# print(mean_height)
# print(mean_width)
# Resizing of the images to give
# Resizing of the images to give
# them same width and height
# them same width and height
for
file
in
os
.
listdir
(
'.'
):
for
file
in
os
.
listdir
(
'.'
):
...
@@ -65,10 +56,12 @@ def generate_video(folderName, enhancedPath, rate):
...
@@ -65,10 +56,12 @@ def generate_video(folderName, enhancedPath, rate):
print
(
im
.
filename
.
split
(
'
\\
'
)[
-
1
],
" is resized"
)
print
(
im
.
filename
.
split
(
'
\\
'
)[
-
1
],
" is resized"
)
# ---------------------------------------------------------------------------------------------------------------
# ---------------------------------------------------------------------------------------------------------------
image_folder
=
'E:
\\
BACKBONE
\\
image_enhancement
\\
Frames
\\
'
+
folderName
+
'
\\
'
+
enhancedPath
# make sure to use your folder
image_folder
=
folderName
video_name
=
'video_'
+
folderName
+
'.avi'
print
(
"imagefolder "
,
image_folder
)
# make sure to use your folder
print
(
"video folder path "
,
video_folder_path
)
# make sure to use your folder
video_name
=
'Enhanced_Video.avi'
os
.
chdir
(
"E:
\\
BACKBONE
\\
image_enhancement
\\
EnhancedVideos
\\
"
+
video_folder_name
)
os
.
chdir
(
video_folder_path
)
images
=
[
img
for
img
in
os
.
listdir
(
image_folder
)
images
=
[
img
for
img
in
os
.
listdir
(
image_folder
)
if
img
.
endswith
(
".jpg"
)
or
if
img
.
endswith
(
".jpg"
)
or
...
@@ -85,7 +78,7 @@ def generate_video(folderName, enhancedPath, rate):
...
@@ -85,7 +78,7 @@ def generate_video(folderName, enhancedPath, rate):
# the width, height of first image
# the width, height of first image
height
,
width
,
layers
=
frame
.
shape
height
,
width
,
layers
=
frame
.
shape
video
=
cv2
.
VideoWriter
(
video_name
,
0
,
rate
,
(
width
,
height
))
video
=
cv2
.
VideoWriter
(
video_name
,
cv2
.
VideoWriter_fourcc
(
*
'MP4V'
)
,
rate
,
(
width
,
height
))
# Appending the images to the video one by one
# Appending the images to the video one by one
for
image
in
images
:
for
image
in
images
:
...
@@ -94,5 +87,5 @@ def generate_video(folderName, enhancedPath, rate):
...
@@ -94,5 +87,5 @@ def generate_video(folderName, enhancedPath, rate):
# Deallocating memories taken for window creation
# Deallocating memories taken for window creation
# cv2.destroyAllWindows()
# cv2.destroyAllWindows()
# video.release() # releasing the video generated
# video.release() # releasing the video generated
return
video_folder_name
+
"
\\
"
+
video_name
print
(
video_folder_path
.
split
(
'
\\
'
)[
4
])
return
video_folder_path
.
split
(
'
\\
'
)[
4
]
\ No newline at end of file
imageEnhancement/ImageSharpening.py
0 → 100644
View file @
64a584d0
import
cv2
import
numpy
as
np
import
os
from
imageEnhancement
import
CreateNewFolderForFrames
from
imageEnhancement
import
RemoveGaussianNoise
def
imageSharp
(
parentFolder
,
ContrastAdjustedFolder
,
rate
):
SharpImages
=
CreateNewFolderForFrames
.
createFolderForSharpImages
(
parentFolder
)
count
=
10000000
for
file
in
os
.
listdir
(
ContrastAdjustedFolder
):
if
file
.
endswith
(
".jpg"
):
image
=
cv2
.
imread
(
ContrastAdjustedFolder
+
"
\\
"
+
file
)
kernel_sharpening
=
np
.
array
([[
-
1
,
-
1
,
-
1
],
[
-
1
,
9
,
-
1
],
[
-
1
,
-
1
,
-
1
]])
# applying the sharpening kernel to the input image & displaying it.
sharpened
=
cv2
.
filter2D
(
image
,
-
1
,
kernel_sharpening
)
cv2
.
imwrite
(
SharpImages
+
"
\\
%
d.jpg"
%
count
,
sharpened
)
count
+=
1
value
=
RemoveGaussianNoise
.
removeGaussianNoise
(
parentFolder
,
SharpImages
,
rate
)
return
value
imageEnhancement/RemoveGaussianNoise.py
0 → 100644
View file @
64a584d0
import
cv2
import
os
from
imageEnhancement
import
CreateNewFolderForFrames
,
FramesToVid
from
imageEnhancement
import
Smooth
def
removeGaussianNoise
(
parentFolder
,
SharpImages
,
rate
):
GaussianDenoised
=
CreateNewFolderForFrames
.
DenoiseGaussian
(
parentFolder
)
count
=
10000000
for
file
in
os
.
listdir
(
SharpImages
):
if
file
.
endswith
(
".jpg"
):
img
=
cv2
.
imread
(
SharpImages
+
"
\\
"
+
file
)
dst
=
cv2
.
fastNlMeansDenoisingColored
(
img
,
None
,
10
,
10
,
7
,
5
)
cv2
.
imwrite
(
GaussianDenoised
+
"
\\
%
d.jpg"
%
count
,
dst
)
count
+=
1
# Smooth.imageSmooth(parentFolder, GaussianDenoised)
value
=
FramesToVid
.
generate_video
(
GaussianDenoised
,
parentFolder
,
rate
)
return
value
imageEnhancement/Smooth.py
0 → 100644
View file @
64a584d0
import
cv2
import
os
from
imageEnhancement
import
CreateNewFolderForFrames
def
imageSmooth
(
parentFolder
,
GaussianDenoised
):
smooth
=
CreateNewFolderForFrames
.
smoothImagesFolder
(
parentFolder
)
count
=
10000000
for
file
in
os
.
listdir
(
GaussianDenoised
):
if
file
.
endswith
(
".jpg"
):
img
=
cv2
.
imread
(
GaussianDenoised
+
"
\\
"
+
file
)
blur
=
cv2
.
bilateralFilter
(
img
,
60
,
90
,
90
)
cv2
.
imwrite
(
smooth
+
"
\\
%
d.jpg"
%
count
,
blur
)
count
+=
1
# if __name__ == '__main__':
# imageSmooth("Frames1", "E:\\BACKBONE\\image_enhancement\\Frames\\Frames1\\Sharp_Frames2")
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment