Virtual Camera and RC Car

IMG_0432

GitHub

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).

The Process:

  • 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 –

  1. 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)
  2. Find and plug in the ethernet cord to the camera
  3. Connect ethernet to Router (Note some setup instructions claim simply plugging ethernet into computer will suffice, I found that a router MUST be used)
  4. 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).
  5. 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)
  6. 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

Screen Shot 2016-05-04 at 1.05.36 AM

Network Settings –

  1. Go into settings (While in Push Mode).
  2. This is where you can use the web app to change all of your camera’s setting
  3. For the Expo we needed a work around due to the lack off router access for the CU network
  4. We created a hotspot on our mobile device. Reconnected the camera. Located our personal hotspot in the Wireless Lan Settings within web app

Screen Shot 2016-05-04 at 1.10.40 AM

Inspecting Code/Analyze how web app works –

  1. With the HTML viewable in chrome, we used the buttons in the web app to move the camera.
  2. 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.
  3. We see this .cgi script is creating a long url, and indeed this url, when put into the browser, moves the camera
  4. Now our python scripts must simply generate those urls appropriately
  5. With Video it proved very similar except with no buttons to press we followed a hint that the “livestream.cgi” was handling video
  6. We did rely on Google and stackoverflow for the python structure on how to parse the http stream

Screen Shot 2016-05-04 at 2.33.37 AM

Screen Shot 2016-05-04 at 2.27.07 AM

Writing the Python Scripts

  1.  Look to github for python script source code
  2. Parsing HTTP Stream
  3. pygame to get keyboard instructions
  4. 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.

References:

**Completed Video Project 1 – GitHub

 

Advertisements
This entry was posted in assignments, Final Project Reports, Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s