MadCam is a web-based security camera application that streams video from a webcam connected to your laptop or desktop. The application is built using Flask for the backend and React for the frontend. It displays the video feed in real-time, along with the current date and time in the Persian calendar.
Before you start, ensure you have the following installed:
- Python 3.x
- A webcam connected to your computer.
git clone https://github.com/yourusername/MadCam.git
cd MadCam
pip install flask opencv-python flask-cors
Navigate to the root of the project where package.json
is located and run:
npm install
npm run build
This will create a production-ready build of the React frontend, placing the output in the build/
directory inside the public/
folder.
In the webcam.py
file, you'll find the following lines:
camera_name = "Microsoft® LifeCam HD-3000"
camera_index_or_path = find_camera_by_name(camera_name)
If you're using a different webcam, you'll need to replace "Microsoft® LifeCam HD-3000"
with the name of your webcam. To find the correct name, you can check your system’s device manager or webcam software.
In the root directory (where webcam.py
is located), run:
python webcam.py
This will start the Flask server on http://localhost:8080
by default, serving both the backend and the frontend.
Open your web browser and go to:
http://localhost:8080
To access your webcam stream remotely:
-
Port Forwarding: Set up port forwarding on your router to forward external requests on port
8080
to your local machine’s IP address (192.168.1.x:8080
). -
Public IP Access: Access the app using your public IP address and the forwarded port. Example:
http://<your-public-ip>:8080
- Blank Screen: Ensure the Flask server is running and the camera is configured correctly.
- Camera Not Detected: Verify that your webcam is connected and working correctly. Update the
camera_name
inwebcam.py
if necessary. - Port Forwarding Not Working: Check your router’s settings and firewall rules.
- Flask Logs: Check the terminal where
webcam.py
is running for any errors.
Contributions are welcome! Please open an issue or submit a pull request.