Skip to content

Commit 7acdb34

Browse files
authored
Merge pull request #2 from yanndebray/main
Improvements coming with Python Importer for Simulink
2 parents efafff7 + 5522250 commit 7acdb34

File tree

93 files changed

+762
-66
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+762
-66
lines changed

.gitattributes

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
* text=auto
2+
3+
*.fig binary
4+
*.mat binary
5+
*.mdl binary diff merge=mlAutoMerge
6+
*.mdlp binary
7+
*.mex* binary
8+
*.mlapp binary
9+
*.mldatx binary
10+
*.mlproj binary
11+
*.mlx binary
12+
*.p binary
13+
*.sfx binary
14+
*.sldd binary
15+
*.slreqx binary merge=mlAutoMerge
16+
*.slmx binary merge=mlAutoMerge
17+
*.sltx binary
18+
*.slxc binary
19+
*.slx binary merge=mlAutoMerge
20+
*.slxp binary
21+
22+
## Other common binary file types
23+
*.docx binary
24+
*.exe binary
25+
*.jpg binary
26+
*.pdf binary
27+
*.png binary
28+
*.xlsx binary

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__pycache__/
2+
slprj/

HumanDetection.slx

64 KB
Binary file not shown.

HumanDetection_import.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"SimulinkCodeImporterVersion": 1,
3+
"LibraryFileName": "HumanDetection",
4+
"CustomCode": {
5+
"SourceFiles": ".\\detectHuman.py",
6+
"GlobalVariableInterface": false
7+
},
8+
"FunctionsToImport": "detectHuman.detectHumanFromFrame",
9+
"FunctionSettings": {
10+
"Name": "detectHuman.detectHumanFromFrame",
11+
"PortSpecArray": [
12+
{
13+
"ArgName": "image",
14+
"PortName": "image",
15+
"Scope": "Output",
16+
"Index": "1",
17+
"Type": "uint8",
18+
"Size": "[300 400 3]",
19+
"IsGlobal": false
20+
},
21+
{
22+
"ArgName": "image",
23+
"PortName": "image",
24+
"Scope": "Input",
25+
"Index": "1",
26+
"Type": "uint8",
27+
"Size": "[480 640 3]",
28+
"IsGlobal": false
29+
}
30+
],
31+
"IsDeterministic": false
32+
}
33+
}

README.MD

Lines changed: 49 additions & 30 deletions

README.mlx

7.43 MB
Binary file not shown.

base_python_example_23a.slx

27.6 KB
Binary file not shown.
27.6 KB
Binary file not shown.

debug.ipynb

Lines changed: 361 additions & 0 deletions
Large diffs are not rendered by default.

detectHuman.py

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
import time
2-
import imutils
2+
# import imutils
33
import numpy as np
4-
from cv2 import cv2
4+
import cv2
5+
import hogClass
56

7+
def detectHumanFromFrame(image):
68

7-
class hogObject:
8-
detector = cv2.HOGDescriptor()
9-
def __init__(self):
10-
self.detector.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())
11-
12-
13-
def getHogObject():
14-
return hogObject()
15-
16-
17-
def detectHumanFromFrame(image, hog):
9+
hog = hogClass.hogObject()
10+
1811
image = np.asarray(image)
19-
image = imutils.resize(image, width=min(400, image.shape[1]))
12+
# image = imutils.resize(image, width=min(400, image.shape[1]))
13+
ratio = image.shape[0] / image.shape[1]
14+
new_height = int(400 * ratio)
15+
image = cv2.resize(image, (400,new_height))
2016

2117
# Detecting all the regions in the Image that has a pedestrians inside it
2218
(regions, _) = hog.detector.detectMultiScale(
@@ -30,8 +26,6 @@ def detectHumanFromFrame(image, hog):
3026

3127

3228
if __name__ == "__main__":
33-
34-
hog = hogObject()
3529

3630
cap = cv2.VideoCapture('livedata.mp4')
3731
ret, image = cap.read()
@@ -41,7 +35,7 @@ def detectHumanFromFrame(image, hog):
4135
# Reading the video stream
4236
ret, image = cap.read()
4337
if ret:
44-
image = detectHumanFromFrame(image, hog)
38+
image = detectHumanFromFrame(image)
4539
cv2.imshow("Image", image)
4640
cv2.waitKey(5)
4741
if cv2.waitKey(5) & 0xFF == ord('q'):

0 commit comments

Comments
 (0)