Commit 5747eecc authored by Chipp Jansen's avatar Chipp Jansen
Browse files

docs

parent 040c4ba6
......@@ -2,91 +2,139 @@
AMRO 2022 Workshop Repository for Documentation
## Getting started
## Connect to your camera
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
We will use `ssh` (Secure Shell) to connect to the camera.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
You will need to find a terminal program (on a Linux or Mac)
on your computer where you can run `ssh` from. On a Windows laptop you can use putty to connect with `ssh`. Let me know if you need help with getting started with `ssh`, we can pair you up with someone who can help.
## Add your files
With the camera's IP address use this command to connect to the camera (this example uses 192.168.1.20 as the IP address, replace it with your camera's IP):
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
ssh root@192.168.1.20
```
cd existing_repo
git remote add origin https://gitlab.servus.at/chipp.jansen/cameras.git
git branch -M main
git push -uf origin main
```
The first thime you do tihs you might get something that says this:
## Integrate with your tools
The authenticity of host '192.168.1.20 (192.168.1.20)' can't be established.
ECDSA key fingerprint is SHA256:8WvDPcIb1JWa7EY34QHHwRV48vnLakWiJ1xTnz9+hJs.
Are you sure you want to continue connecting (yes/no/[fingerprint])?
- [ ] [Set up project integrations](https://gitlab.servus.at/chipp.jansen/cameras/-/settings/integrations)
Type `yes` and hit ENTER.
## Collaborate with your team
The password to use is `root`.
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
If successful, you will get a command prompt that looks like this:
## Test and Deploy
#
Use the built-in continuous integration in GitLab.
You can check which camera you are on by reading the hostname file on the camera:
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
more /etc/hostname
***
It should be the name that is on the camera. If it does not match, you might have connected to someone elses camera! You can type the command `exit` to close the connection and try the `ssh` command again with a different IP address.
# Editing this README
## Set-up of the camera
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
The camera filesystem is set-up with a "traditional" Linux filesystem. You can list the directories at the root of the file system:
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
ls /
## Name
Choose a self-explaining name for your project.
There is a directory `/sdcard` which is the sdcard of the camera. If you don't see a sdcard directory, let me know. You will need it to run the programs on the camera.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
Change directory to the sdcard to see what is there.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
cd /sdcard
ls
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## See what is running on the camera
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
You can see what programs are running on the camera and other activity statistics by running `htop`.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
htop
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
You will see a listing like this, which updates periodically to show what is running.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
You can use the up/down arrows to see the different programs running. Notice the `videocapture`, `mjpg_streamer` and `rtsp...`.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
## View the stream
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
If you have `mjpg_streamer` running, then you can view the stream, by openning a browser to (again, substitute your IP instead of 192.168.1.20):
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
http://192.168.1.20:8080/?action=stream
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## Grab snapshots of the stream
## License
For open source projects, say how it is licensed.
`mjpg_streamer` also supports grabbing single JPGs of the stream. You can grab an image using the `curl` utility, which let's you do HTTP requests (i.e. grab web-pages) from the command line.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
curl -o /sdcard/snaps/test.jpg http://localhost:8080/?action=snapshot
This downloads a jpg into the `snaps` directory on the sdcard.
ls /sdcard/snaps
Note that instead of using your specific IP, we can use `localhost` in the URL to substitute your own IP address when running programs from your camera.
## Stream that JPG!
Now we will set-up our own seperate hacky stream that will display this jpg. This will run on a seperate port (note the 8081 in the command) on the camera:
mjpg_streamer -i "input_file.so -f /sdcard/snaps" -o "output_http.so -p 8081" > /dev/null 2>&1 &
The `&` means this program will run in the background, and you can continue typing on the command prompt. You can run `htop` and find this version of `mjpg_streamer` running. We are running two seperate `mjpg_streamer` programs.
## Refresh that jpg
`mjpg_streamer` will watch the `snaps` directory for refreshed `test.jpg` to steam. So we will use the `watch` command to re-run the `curl` command once a second (by setting the `-n 1` option).
watch -n 1 curl -o /sdcard/snaps/test.jpg http://localhost:8080/?action=snapshot
## View our hacky stream
Now using a slightly different url in the browser, we can view our every second "stream" (note that the only difference with this url is the port 8081 instead):
http://192.168.1.20:8081/?action=stream
***Congratulations!*** You've set-up your own stream.
## Before we modify the stream...
Now, we can manipulate the image from the camera every time we download it and the modified image is then streamed on a seperate.
But wait! Unfortunately our little camera cannot handle manipulating the images at the current resolution, which is 1920 by 1080. The camera will run out of memory and the conversion will crash!
So we need to get the `videocapture` program to streamer a smaller resolution for performance reasons.
First, we need to stop the current running programs. You can easily stop ALL programs running with that name using `killall`. So to stop `videocapture` and `mjpg_streamer`:
killall videocapture
killall mjpg_streamer
You can check `htop` to make sure they are stopped.
Next, we will restart `videocapture` with a configuration file (that is already on the sdcard at `/sdcard/mjpeg.json`) that sets it to stream at 320 by 180:
/usr/bin/videocapture /sdcard/mjpeg.json >> /var/log/videocapture.log 2>&1 &
Next, we will restart streaming this original image with `mjpg_streamer`:
mjpg_streamer -i "input_v4l2loopback.so -d /dev/video4 --fps 15" -o "output_http.so" > /dev/null 2>&1 &
This is the exactly same command as before, and streams to port 8080. We can refresh the browser to view this smaller stream:
http://192.168.1.20:8080/?action=stream
## Modify the stream
Now, we can use imagemagick's `convert` program to manipulate and produce a new image that we can stream.
Let's test this out first with a single image.
**Step 1** we grab this smaller image using curl (without `watch`) into the `snaps` directory (as before):
curl -o /sdcard/snaps/test.jpg http://localhost:8080/?action=snapshot
Next, we convert this image, we will use the `swirl` option which swirls the center of the image by a number of degrees. Imagemagick's `convert` has SO MANY options to manipulate the image (such as drawing etc...).
convert /sdcard/snaps/test.jpg -swirl 60 /sdcard/stream/out.jpg
Finally, we run our new `mjpg_streamer` which will stream images from a separate
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment