pyaidrone 1.18__tar.gz → 2.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.
- {pyaidrone-1.18 → pyaidrone-2.0}/PKG-INFO +1 -1
- {pyaidrone-1.18 → pyaidrone-2.0}/pyaidrone/aiDrone.py +1 -1
- {pyaidrone-1.18 → pyaidrone-2.0}/pyaidrone/deflib.py +0 -1
- {pyaidrone-1.18 → pyaidrone-2.0}/pyaidrone/edu.py +52 -9
- {pyaidrone-1.18 → pyaidrone-2.0}/pyaidrone.egg-info/PKG-INFO +1 -1
- {pyaidrone-1.18 → pyaidrone-2.0}/setup.py +1 -1
- {pyaidrone-1.18 → pyaidrone-2.0}/README.md +0 -0
- {pyaidrone-1.18 → pyaidrone-2.0}/pyaidrone/__init__.py +0 -0
- {pyaidrone-1.18 → pyaidrone-2.0}/pyaidrone/ikeyevent.py +0 -0
- {pyaidrone-1.18 → pyaidrone-2.0}/pyaidrone/packet.py +0 -0
- {pyaidrone-1.18 → pyaidrone-2.0}/pyaidrone/parse.py +0 -0
- {pyaidrone-1.18 → pyaidrone-2.0}/pyaidrone/sensor.py +0 -0
- {pyaidrone-1.18 → pyaidrone-2.0}/pyaidrone/vision_ai.py +0 -0
- {pyaidrone-1.18 → pyaidrone-2.0}/pyaidrone.egg-info/SOURCES.txt +0 -0
- {pyaidrone-1.18 → pyaidrone-2.0}/pyaidrone.egg-info/dependency_links.txt +0 -0
- {pyaidrone-1.18 → pyaidrone-2.0}/pyaidrone.egg-info/requires.txt +0 -0
- {pyaidrone-1.18 → pyaidrone-2.0}/pyaidrone.egg-info/top_level.txt +0 -0
- {pyaidrone-1.18 → pyaidrone-2.0}/setup.cfg +0 -0
|
@@ -50,7 +50,7 @@ class AIDrone(Parse, Packet):
|
|
|
50
50
|
exit()
|
|
51
51
|
return False
|
|
52
52
|
try:
|
|
53
|
-
self.serial = serial.Serial(port=portName, baudrate=
|
|
53
|
+
self.serial = serial.Serial(port=portName, baudrate=19200, timeout=1)
|
|
54
54
|
if self.serial.isOpen():
|
|
55
55
|
self.isThreadRun = True
|
|
56
56
|
self.thread = Thread(target=self.receiveHandler, args=(), daemon=True)
|
|
@@ -22,6 +22,7 @@ class EduAIDrone:
|
|
|
22
22
|
self.cap = None
|
|
23
23
|
self.last_frame = None
|
|
24
24
|
self.height = 100 # 기본 유지 고도
|
|
25
|
+
self.stream_url = None
|
|
25
26
|
|
|
26
27
|
# --- 연결 및 영상 관리 ---
|
|
27
28
|
def connect(self):
|
|
@@ -33,16 +34,46 @@ class EduAIDrone:
|
|
|
33
34
|
return False
|
|
34
35
|
|
|
35
36
|
def start_stream(self, url="http://192.168.4.1/?action=stream"):
|
|
36
|
-
|
|
37
|
+
self.stream_url = url # ← URL 저장
|
|
37
38
|
self.cap = cv2.VideoCapture(url)
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
|
|
40
|
+
if self.cap.isOpened():
|
|
41
|
+
self.cap.set(cv2.CAP_PROP_BUFFERSIZE, 1) # ← 버퍼 설정
|
|
42
|
+
print(f"✅ 스트림 연결: {url}")
|
|
43
|
+
return True
|
|
44
|
+
else:
|
|
45
|
+
print(f"❌ 스트림 연결 실패: {url}")
|
|
46
|
+
return False
|
|
47
|
+
|
|
40
48
|
def update_screen(self, window_name="AI Drone Edu"):
|
|
41
|
-
"""
|
|
42
|
-
|
|
43
|
-
if
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
"""안전한 프레임 업데이트"""
|
|
50
|
+
# 1. cap이 None인지 확인
|
|
51
|
+
if self.cap is None:
|
|
52
|
+
print("⚠️ 스트림이 연결되지 않았습니다")
|
|
53
|
+
return None
|
|
54
|
+
|
|
55
|
+
# 2. AttributeError 처리
|
|
56
|
+
try:
|
|
57
|
+
ret, frame = self.cap.read()
|
|
58
|
+
except AttributeError:
|
|
59
|
+
print("❌ cap.read() 에러")
|
|
60
|
+
self.cap = None
|
|
61
|
+
return None
|
|
62
|
+
|
|
63
|
+
# 3. 프레임 검증
|
|
64
|
+
if not ret or frame is None:
|
|
65
|
+
return None
|
|
66
|
+
|
|
67
|
+
# 4. 안전한 리사이즈
|
|
68
|
+
try:
|
|
69
|
+
if frame.size == 0: # ← 크기 체크 추가!
|
|
70
|
+
return None
|
|
71
|
+
|
|
72
|
+
self.last_frame = cv2.resize(frame, (640, 480))
|
|
73
|
+
return self.last_frame
|
|
74
|
+
except Exception as e:
|
|
75
|
+
print(f"⚠️ 리사이즈 에러: {e}")
|
|
76
|
+
return None
|
|
46
77
|
|
|
47
78
|
# --- 단순 제어 명령어 ---
|
|
48
79
|
def takeoff(self):
|
|
@@ -142,4 +173,16 @@ class EduAIDrone:
|
|
|
142
173
|
|
|
143
174
|
timestamp = time.strftime("%H%M%S")
|
|
144
175
|
filename = f"{folder}/target_{timestamp}.jpg"
|
|
145
|
-
cv2.imwrite(filename, frame)
|
|
176
|
+
cv2.imwrite(filename, frame)
|
|
177
|
+
|
|
178
|
+
def reconnect_stream(self):
|
|
179
|
+
"""스트림 재연결"""
|
|
180
|
+
if self.stream_url is None:
|
|
181
|
+
return False
|
|
182
|
+
|
|
183
|
+
if self.cap:
|
|
184
|
+
self.cap.release()
|
|
185
|
+
self.cap = None
|
|
186
|
+
|
|
187
|
+
time.sleep(1)
|
|
188
|
+
return self.start_stream(self.stream_url)
|
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name="pyaidrone",
|
|
5
|
-
version="
|
|
5
|
+
version="2.0",
|
|
6
6
|
description="Library for AIDrone Products",
|
|
7
7
|
long_description=open("README.md").read(), # README.md 내용을 long_description으로 사용
|
|
8
8
|
long_description_content_type="text/markdown", # README 파일이 markdown 형식임을 지정
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|