From 0ecd4a0ec8c4c5585cbd8975d7786c5618814381 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期三, 03 十二月 2025 08:28:59 +0800
Subject: [PATCH] #

---
 README.md |  211 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 210 insertions(+), 1 deletions(-)

diff --git a/README.md b/README.md
index 7ed34d2..1e365b6 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,213 @@
-## hik-video
+# 娴峰悍宸ヤ笟鐩告満HTTP API鏈嶅姟
 
+閫氳繃FastAPI鎻愪緵HTTP鎺ュ彛鎺у埗娴峰悍宸ヤ笟鐩告満鎷嶇収
 
+## 鍔熻兘鐗规��
 
+- 鉁� 鏀寔澶氱浉鏈虹鐞�
+- 鉁� 閫氳繃IP鍦板潃銆佸簭鍒楀彿銆佺储寮曢�夋嫨鐩告満
+- 鉁� RESTful API鎺ュ彛
+- 鉁� 鑷姩鍥惧儚鏍煎紡杞崲锛圔MP/JPG锛�
+- 鉁� 鍥剧墖涓嬭浇鎺ュ彛
+- 鉁� 瀹屾暣鐨勯敊璇鐞�
+
+## 瀹夎渚濊禆
+
+```bash
+pip install -r requirements.txt
+```
+
+## 鍚姩鏈嶅姟
+
+```bash
+python camera_api.py
+```
+
+鏈嶅姟灏嗗湪 `http://localhost:8000` 鍚姩
+
+## API鏂囨。
+
+鍚姩鏈嶅姟鍚庤闂細
+- Swagger UI: http://localhost:8000/docs
+- ReDoc: http://localhost:8000/redoc
+
+## API鎺ュ彛
+
+### 1. 鍒楀嚭鎵�鏈夌浉鏈�
+
+**GET** `/cameras`
+
+鍝嶅簲绀轰緥锛�
+```json
+{
+  "success": true,
+  "count": 2,
+  "cameras": [
+    {
+      "index": 0,
+      "type": "GigE",
+      "model": "MV-CS200-10GC",
+      "serial": "00J12345678",
+      "ip": "192.168.1.100",
+      "user_defined_name": "Camera1"
+    }
+  ]
+}
+```
+
+### 2. 鎷嶇収锛堥�氳繃IP鍦板潃锛�
+
+**GET** `/capture?ip=192.168.1.100&filename=test_image`
+
+**POST** `/capture`
+```json
+{
+  "ip": "192.168.1.100",
+  "filename": "test_image",
+  "save_bmp": true,
+  "save_jpg": true,
+  "timeout": 3000
+}
+```
+
+鍝嶅簲绀轰緥锛�
+```json
+{
+  "success": true,
+  "message": "鎷嶇収鎴愬姛",
+  "files": ["test_image.bmp", "test_image.jpg"],
+  "camera_info": {
+    "type": "GigE",
+    "model": "MV-CS200-10GC",
+    "serial": "00J12345678",
+    "ip": "192.168.1.100"
+  }
+}
+```
+
+### 3. 鎷嶇収锛堥�氳繃搴忓垪鍙凤級
+
+**GET** `/capture_by_serial?serial=00J12345678&filename=test_image`
+
+### 4. 鎷嶇収锛堥�氳繃绱㈠紩锛�
+
+**GET** `/capture_by_index?index=0&filename=test_image`
+
+### 5. 涓嬭浇鍥剧墖
+
+**GET** `/image/test_image.jpg`
+
+### 6. 鍋ュ悍妫�鏌�
+
+**GET** `/health`
+
+## 浣跨敤绀轰緥
+
+### Python瀹㈡埛绔�
+
+```python
+import requests
+
+# 鍒楀嚭鎵�鏈夌浉鏈�
+response = requests.get("http://localhost:8000/cameras")
+cameras = response.json()["cameras"]
+
+# 閫氳繃IP鍦板潃鎷嶇収
+response = requests.get(
+    "http://localhost:8000/capture",
+    params={
+        "ip": "192.168.1.100",
+        "filename": "my_image"
+    }
+)
+result = response.json()
+print(f"淇濆瓨鐨勬枃浠�: {result['files']}")
+
+# 涓嬭浇鍥剧墖
+response = requests.get("http://localhost:8000/image/my_image.jpg")
+with open("downloaded.jpg", "wb") as f:
+    f.write(response.content)
+```
+
+### cURL
+
+```bash
+# 鍒楀嚭鐩告満
+curl http://localhost:8000/cameras
+
+# 鎷嶇収锛圙ET锛�
+curl "http://localhost:8000/capture?ip=192.168.1.100&filename=test_image"
+
+# 鎷嶇収锛圥OST锛�
+curl -X POST http://localhost:8000/capture \
+  -H "Content-Type: application/json" \
+  -d '{"ip":"192.168.1.100","filename":"test_image"}'
+
+# 涓嬭浇鍥剧墖
+curl -O http://localhost:8000/image/test_image.jpg
+```
+
+### JavaScript/Fetch
+
+```javascript
+// 鍒楀嚭鐩告満
+fetch('http://localhost:8000/cameras')
+  .then(res => res.json())
+  .then(data => console.log(data));
+
+// 鎷嶇収
+fetch('http://localhost:8000/capture?ip=192.168.1.100&filename=test_image')
+  .then(res => res.json())
+  .then(data => console.log(data));
+
+// 涓嬭浇鍥剧墖
+fetch('http://localhost:8000/image/test_image.jpg')
+  .then(res => res.blob())
+  .then(blob => {
+    const url = window.URL.createObjectURL(blob);
+    const a = document.createElement('a');
+    a.href = url;
+    a.download = 'test_image.jpg';
+    a.click();
+  });
+```
+
+## 娴嬭瘯
+
+杩愯娴嬭瘯瀹㈡埛绔細
+
+```bash
+python test_api.py
+```
+
+## 鏂囦欢璇存槑
+
+- `camera_api.py` - FastAPI鏈嶅姟涓绘枃浠�
+- `camera_manager.py` - 鐩告満绠$悊绫�
+- `test_api.py` - API娴嬭瘯瀹㈡埛绔�
+- `test.py` - 鍩虹娴嬭瘯鑴氭湰
+- `example_multi_camera.py` - 澶氱浉鏈轰娇鐢ㄧず渚�
+- `requirements.txt` - Python渚濊禆
+
+## 娉ㄦ剰浜嬮」
+
+1. 纭繚鐩告満宸叉纭繛鎺ュ苟閰嶇疆濂界綉缁�
+2. 鍏抽棴娴峰悍MVS瀹㈡埛绔蒋浠讹紝閬垮厤璁惧鍗犵敤
+3. 鍥剧墖榛樿淇濆瓨鍦ㄥ綋鍓嶇洰褰�
+4. 寤鸿鍦ㄧ敓浜х幆澧冧腑娣诲姞璁よ瘉鍜屾潈闄愭帶鍒�
+5. 鍙互閫氳繃鐜鍙橀噺閰嶇疆鏈嶅姟绔彛鍜屼繚瀛樿矾寰�
+
+## 鏁呴殰鎺掗櫎
+
+### 閿欒锛氳澶囨棤璁块棶鏉冮檺 (0x80000203)
+- 鍏抽棴娴峰悍MVS瀹㈡埛绔�
+- 纭繚娌℃湁鍏朵粬绋嬪簭鍗犵敤鐩告満
+
+### 閿欒锛氳幏鍙栧浘鍍忓け璐� (0x80000007)
+- 妫�鏌ョ浉鏈洪暅澶寸洊鏄惁鎵撳紑
+- 纭繚鏈夎冻澶熷厜绾�
+- 澧炲姞timeout鍙傛暟鍊�
+
+### 閿欒锛氭棤娉曡繛鎺ュ埌API鏈嶅姟
+- 纭繚鏈嶅姟宸插惎鍔細`python camera_api.py`
+- 妫�鏌ョ鍙�8000鏄惁琚崰鐢�

--
Gitblit v1.9.1