hexss 0.2.2__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. {hexss-0.2.2 → hexss-0.3.0}/PKG-INFO +1 -1
  2. hexss-0.3.0/hexss/constants/__init__.py +1 -0
  3. hexss-0.3.0/hexss/example/multicore.py +33 -0
  4. hexss-0.3.0/hexss/example/multicore2.py +56 -0
  5. hexss-0.3.0/hexss/multiprocessing/__init__.py +2 -0
  6. hexss-0.3.0/hexss/multiprocessing/multicore.py +23 -0
  7. {hexss-0.2.2 → hexss-0.3.0}/hexss.egg-info/PKG-INFO +1 -1
  8. {hexss-0.2.2 → hexss-0.3.0}/hexss.egg-info/SOURCES.txt +4 -0
  9. {hexss-0.2.2 → hexss-0.3.0}/setup.py +1 -1
  10. hexss-0.2.2/hexss/example/__init__.py +0 -0
  11. {hexss-0.2.2 → hexss-0.3.0}/LICENSE +0 -0
  12. {hexss-0.2.2 → hexss-0.3.0}/hexss/__init__.py +0 -0
  13. {hexss-0.2.2 → hexss-0.3.0}/hexss/constants/cml.py +0 -0
  14. {hexss-0.2.2/hexss/constants → hexss-0.3.0/hexss/example}/__init__.py +0 -0
  15. {hexss-0.2.2 → hexss-0.3.0}/hexss/example/camera_server.py +0 -0
  16. {hexss-0.2.2 → hexss-0.3.0}/hexss/example/example.py +0 -0
  17. {hexss-0.2.2 → hexss-0.3.0}/hexss/json/__init__.py +0 -0
  18. {hexss-0.2.2 → hexss-0.3.0}/hexss/json/json_utils.py +0 -0
  19. /hexss-0.2.2/hexss/multiprocessing/__init__.py → /hexss-0.3.0/hexss/multiprocessing/func.py +0 -0
  20. {hexss-0.2.2 → hexss-0.3.0}/hexss/server/__init__.py +0 -0
  21. {hexss-0.2.2 → hexss-0.3.0}/hexss/server/camera_server.py +0 -0
  22. {hexss-0.2.2 → hexss-0.3.0}/hexss/server/templates/simulate_CCTV.html +0 -0
  23. {hexss-0.2.2 → hexss-0.3.0}/hexss.egg-info/dependency_links.txt +0 -0
  24. {hexss-0.2.2 → hexss-0.3.0}/hexss.egg-info/top_level.txt +0 -0
  25. {hexss-0.2.2 → hexss-0.3.0}/setup.cfg +0 -0
@@ -1,4 +1,4 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hexss
3
- Version: 0.2.2
3
+ Version: 0.3.0
4
4
  License-File: LICENSE
@@ -0,0 +1 @@
1
+ from .cml import *
@@ -0,0 +1,33 @@
1
+ import time
2
+ from hexss.constants import RED, BLUE, ENDC
3
+ from hexss.multiprocessing import Multicore
4
+
5
+
6
+ def func1(data):
7
+ while True:
8
+ data['func1'] = data.get('func1', 0) + 1
9
+ data['list'].append(data['func1'])
10
+ if len(data['list']) > 20:
11
+ data['list'] = data['list'][:20]
12
+ print(f'{RED}{data["func1"]} {data['list']}{ENDC}')
13
+ time.sleep(1)
14
+
15
+
16
+ def func2(data):
17
+ while True:
18
+ data['func2'] = data.get('func2', 0) + 1
19
+ print(f'{BLUE}{data["func2"]}{ENDC}')
20
+ time.sleep(2)
21
+
22
+
23
+ if __name__ == '__main__':
24
+ m = Multicore()
25
+ m.set_data({
26
+ 'func1': -50,
27
+ 'func2': -50,
28
+ 'list': []
29
+ })
30
+ m.add_func(func1)
31
+ m.add_func(func2)
32
+ m.start()
33
+ m.join()
@@ -0,0 +1,56 @@
1
+ import cv2
2
+ from hexss.multiprocessing import Multicore
3
+
4
+
5
+ def capture_video(data):
6
+ cap = cv2.VideoCapture(0)
7
+ if not cap.isOpened():
8
+ print("Error: Could not open camera.")
9
+ data['play'] = False
10
+ return
11
+
12
+ while data['play']:
13
+ ret, frame = cap.read()
14
+ if not ret:
15
+ print("Error: Failed to capture frame.")
16
+ data['play'] = False
17
+ data['frame'] = frame.copy()
18
+ cap.release()
19
+
20
+
21
+ def process_video(data):
22
+ while data['play']:
23
+ if 'frame' in data and data['frame'] is not None:
24
+ cv2.imshow('frame', data['frame'])
25
+ if cv2.waitKey(1) & 0xFF == ord('q'):
26
+ data['play'] = False
27
+ cv2.destroyAllWindows()
28
+
29
+
30
+ # def capture_video(data):
31
+ # cap = cv2.VideoCapture(0)
32
+ # while data['play']:
33
+ # ret, frame = cap.read()
34
+ # data['frame'] = frame.copy()
35
+ #
36
+ #
37
+ # def process_video(data):
38
+ # while data['play']:
39
+ # if data['frame'] is not None:
40
+ # cv2.imshow('frame', data['frame'])
41
+ #
42
+ # if cv2.waitKey(1) & 0xFF == ord('q'):
43
+ # data['play'] = False
44
+ #
45
+ # cv2.destroyAllWindows()
46
+
47
+ if __name__ == '__main__':
48
+ m = Multicore()
49
+ m.set_data({
50
+ 'play': True,
51
+ 'frame': None,
52
+ })
53
+ m.add_func(capture_video)
54
+ m.add_func(process_video)
55
+ m.start()
56
+ m.join()
@@ -0,0 +1,2 @@
1
+ from .multicore import Multicore
2
+ from .func import dict_to_manager_dict, list_to_manager_list
@@ -0,0 +1,23 @@
1
+ from multiprocessing import Process, Manager
2
+ from hexss.multiprocessing.func import dict_to_manager_dict
3
+
4
+
5
+ class Multicore:
6
+ def __init__(self):
7
+ self.processes = []
8
+ self.manager = Manager()
9
+ self.data = self.manager.dict()
10
+
11
+ def set_data(self, data: dict):
12
+ self.data = dict_to_manager_dict(self.manager, data)
13
+
14
+ def add_func(self, func):
15
+ self.processes.append(Process(target=func, args=(self.data,)))
16
+
17
+ def start(self):
18
+ for process in self.processes:
19
+ process.start()
20
+
21
+ def join(self):
22
+ for process in self.processes:
23
+ process.join()
@@ -1,4 +1,4 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hexss
3
- Version: 0.2.2
3
+ Version: 0.3.0
4
4
  License-File: LICENSE
@@ -10,9 +10,13 @@ hexss/constants/cml.py
10
10
  hexss/example/__init__.py
11
11
  hexss/example/camera_server.py
12
12
  hexss/example/example.py
13
+ hexss/example/multicore.py
14
+ hexss/example/multicore2.py
13
15
  hexss/json/__init__.py
14
16
  hexss/json/json_utils.py
15
17
  hexss/multiprocessing/__init__.py
18
+ hexss/multiprocessing/func.py
19
+ hexss/multiprocessing/multicore.py
16
20
  hexss/server/__init__.py
17
21
  hexss/server/camera_server.py
18
22
  hexss/server/templates/simulate_CCTV.html
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='hexss',
5
- version='0.2.2',
5
+ version='0.3.0',
6
6
  packages=find_packages(),
7
7
  include_package_data=True,
8
8
  install_requires=[],
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes