Skip to content

Commit

Permalink
webcam working
Browse files Browse the repository at this point in the history
  • Loading branch information
jwmke committed Mar 30, 2024
1 parent 311938b commit 46e4e6f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/api/v1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ python3.11 -m venv venv
```

From here, you can source your venv with the following commands.
Windows, probably:

Windows:

```
./venv/bin/Activate.ps1
.\venv\Scripts\Activate.ps1
```

Linux:
Expand Down
4 changes: 2 additions & 2 deletions src/api/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import cv2

app = FastAPI()
camera = cv2.VideoCapture(0, cv2.CAP_DSHOW)
camera = cv2.VideoCapture(1, cv2.CAP_DSHOW)
templates = Jinja2Templates(directory="templates")


Expand All @@ -32,6 +32,6 @@ async def get_stream(websocket: WebSocket):
else:
ret, buffer = cv2.imencode(".jpg", frame)
await websocket.send_bytes(buffer.tobytes())
await asyncio.sleep(0.03)
await asyncio.sleep(0.01)
except (WebSocketDisconnect, ConnectionClosed):
print("Client disconnected")
2 changes: 1 addition & 1 deletion src/api/v1/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ sniffio==1.3.1
starlette==0.36.3
typing_extensions==4.10.0
uvicorn==0.29.0
uvloop==0.19.0
# uvloop==0.19.0
watchfiles==0.21.0
websockets==12.0

0 comments on commit 46e4e6f

Please sign in to comment.