forked from inomuh/camfitool
-
Notifications
You must be signed in to change notification settings - Fork 1
/
class_fi_realtime_ui.py
60 lines (49 loc) · 1.79 KB
/
class_fi_realtime_ui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Real-time Fault Injection Python Class For Camera FI Demo Tool
"""
import cv2
from cv_bridge import CvBridge
class RealtimeImageFault:
"""
TOF/RGB Camera Image (Realtime) Fault Library For Camera FI Demo Tool
----------------------------------------------------------------
### Variables:
- image = Stream image
- kernel = Image kernel info
- fault_type: Choosing fault type
- fault_rate: Fault rate (%)
### Image Faults :
- Salt&Pepper -> salt_pepper() (Under-development)
- Gaussian -> gaussian() (Under-development)
- Poisson -> poisson() (Under-development)
- Erosion -> erosion()
- Dilation -> dilation()
- Gradient -> gradient()
- Partialloss -> partialloss() (Under-development)
###### Created by AKE - 23.08.22
"""
def __init__(self, image, kernel, fault_type, fault_rate):
self.img = image
self.kernel = kernel
self.fault_type = fault_type
self.fault_rate = fault_rate
self.bridge = CvBridge()
def dilation(self):
"""Dilation Fault Method"""
return cv2.dilate(self.img,self.kernel, iterations = 5)
def erosion(self):
"""Erosion Fault Method"""
return cv2.erode(self.img,self.kernel, iterations = 5)
def gradient(self):
"""Gradient Fault Method"""
return cv2.morphologyEx(self.img, cv2.MORPH_GRADIENT, self.kernel)
def partialloss(self):
"""Partialloss Fault Method (Under-development)"""
def saltpepper(self):
"""Salt&Pepper Fault Method (Under-development)"""
def gaussian(self):
"""Gaussian Fault Method (Under-development)"""
def poisson(self):
"""Poisson Fault Method (Under-development)"""