The inspiration behind Virtual Camera was that we wanted to add “A first-person view and experience to RC projects everywhere”. While we didn’t quite reach the “Virtual Reality” stages for the camera we did make great progress including integrating the camera with an upgraded version of our RC Car (look to end of post for RC Car detail).
- Choose/buy camera (we chose the Kaicong sip1303)
- Get Camera working (as designed) out of box – Not Trivial with Chinese instructions
- Inspect KaiCong Web App through Chrome (look at HTML elements while clicking around)
- Create Python Scripts (aka Replace Web App):
- Intercept HTTP Packets (for Video)
- Send motor position instructions
- Convert Python scripts to a deployable phone application
- Convert video to Virtual Reality format
Searching the web I found a few Instructables detailing similar projects. One (made by the people at fabericate.io) even gave a great tutorial on how to hack a different KaiCong camera (useful libraries included!).
Plug In Camera –
- Find and plug in power supply to camera and outlet (don’t be alarmed, when initially plugged in, camera may complete a full pan/tilt calibrating routine)
- Find and plug in the ethernet cord to the camera
- Connect ethernet to Router (Note some setup instructions claim simply plugging ethernet into computer will suffice, I found that a router MUST be used)
- All KaiCong’s have a domain address printed on the camera. Find and copy the domain into your browser, it should begin with a unique 6 digit number followed by “.kaicong.info” (ours is 487285.kaicong.info).
- If everything is working your “Username and Password” will be prompted when your domain address is entered into your browser (key point of failure if network issues are occurring)
- You now should see a few different modes for displaying the video – choose Push Mode and your camera feed should be viewable. Take Note – Your camera’s ip address is in the URL bar at the top of your browser
Network Settings –
- Go into settings (While in Push Mode).
- This is where you can use the web app to change all of your camera’s setting
- For the Expo we needed a work around due to the lack off router access for the CU network
- We created a hotspot on our mobile device. Reconnected the camera. Located our personal hotspot in the Wireless Lan Settings within web app
Inspecting Code/Analyze how web app works –
- With the HTML viewable in chrome, we used the buttons in the web app to move the camera.
- With the network activity tab chosen you can see a list of GET methods and the more you move the camera, the more you will see of a method of type XHR, notice it has an associated script called “decoder_control.cgi”. This moves the camera.
- We see this .cgi script is creating a long url, and indeed this url, when put into the browser, moves the camera
- Now our python scripts must simply generate those urls appropriately
- With Video it proved very similar except with no buttons to press we followed a hint that the “livestream.cgi” was handling video
- We did rely on Google and stackoverflow for the python structure on how to parse the http stream
Writing the Python Scripts
- Look to github for python script source code
- Parsing HTTP Stream
- pygame to get keyboard instructions
- OpenCV for video
RC Car Integration
We spliced the camera cord, connected it a computer via a personal hotspot, and attached to the car. But we wanted to try and integrate the camera further, so we pushed to have our RC controller (Xbox) move the camera, that way someone can move the car with their left thumb and the camera with their right. Look to VirtualMotorXbee.py. Unfortunately we only had two XBee’s thus had to use our RC Car XBee to attach to our computer. We used the same structure as our original VirtualMotor code but now introduce a serial read to check incoming xbox controller commands. The camera only moves left and right but is functional (Look to project 2 about serial communication). While we may not have a full car, camera, and display assembly (we would need 3 XBees) it successfully proves the macro concept. We also had to spend some time fixing some RC Car bugs, namely, we had to correct how the Arduino handled simultaneous commands (i.e. left and forward, right and reverse) – New RC Car Code in VirtualCamera repo.
**Completed Video Project 1 – GitHub