Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera Module Tutorial #83

Merged
merged 2 commits into from
Apr 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ <h1><a href="https://tessel.io/"><nobr><img src=
<a href="{{ site.baseurl }}/modules/ble.html" class=
"side-bar-modules">ble</a>
</li>
<li style="padding-left:10px;">
<a href="{{ site.baseurl }}/modules/camera.html" class=
"side-bar-modules">camera</a>
</li>
<li style="padding-left:10px;">
<a href="{{ site.baseurl }}/modules/climate.html" class=
"side-bar-modules">climate</a>
Expand Down
2 changes: 2 additions & 0 deletions modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ If you've already tried out your modules, move on to [Tweet.](tweet.html)
* [Accelerometer](modules/accelerometer.html)
* [Ambient (Light + Sound)](modules/ambient.html)
* [BLE](modules/ble.html)
* [Camera](modules/camera.html)
* [Climate](modules/climate.html)
* [GPS](modules/gps.html)
* [Infrared](modules/ir.html)
* [Relay](modules/relay.html)
* [RFID](modules/rfid.html)
* [Servo](modules/servo.html)


<div class="greyBar"></div>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions modules/_module_footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ <h2>Choose another module</h2>
<a href="ble.html"><span class=
"moduleLink">BLE</span></a>
</li>
<li>
<a href="camera.html"><span class=
"moduleLink">Camera</span></a>
</li>
<li>
<a href="climate.html"><span class=
"moduleLink">Climate</span></a>
Expand Down
10 changes: 10 additions & 0 deletions modules/camera.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
layout: default
---

{% capture include_install %}
{% include_relative camera.md %}
{% endcapture %}
{{ include_install | markdownify }}

{% include_relative _module_footer.html %}
122 changes: 122 additions & 0 deletions modules/camera.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{::options parse_block_html="true" /}

<div class="row">
<div class="large-12 columns">

## <img class="constrain-sm" src="https://s3.amazonaws.com/technicalmachine-assets/technical-io/modules/usb.png"> Camera

[<i class="fa fa-github"> View source on Github</i>](https://github.com/tessel/tessel-av)

### Step 1

Make a directory inside your "tessel-code" folder called "camera", change directory into that folder, and initialize a tessel project:

`mkdir camera; cd camera; t2 init`

### Step 2
</div>
</div>

<div class="row">
<div class="large-6 columns">

Plug Tessel into your computer via USB, then plug the camera module into either of Tessel's USB ports. You will also need a [UVC compatible USB camera](https://tessel.io/modules#tessel-av).

</div>
<div class="large-6 columns">

![](http://i.imgur.com/uifn1p7.jpg)

</div>
</div>

<div class="row">
<div class="large-12 columns">

### Step 3

Install by typing `npm install tessel-av` into the command line.

### Step 4

Rename "index.js" to "camera.js" and replace the file's contents with the following:

{% highlight js %}
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/publicdomain/zero/1.0/

/*********************************************
Create a server that responds to every request by taking a picture and piping it directly to the browser.
*********************************************/

var av = require('tessel-av');
var os = require('os');
var http = require('http');
var port = 8080;
var camera = new av.Camera();

http.createServer((request, response) => {
response.writeHead(200, { 'Content-Type': 'image/jpg' });

camera.capture().pipe(response);

}).listen(port, () => console.log(`http://${os.hostname()}.local:${port}`));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the wrong quote types

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats a template string.


{% endhighlight %}

Save the file.

</div>
</div>

<div class="row">
<div class="large-12 columns">

### Step 5

</div>
</div>

<div class="row">
<div class="large-6 columns">

In your command line, `t2 run camera.js`

Hooray! You should see the following in your terminal:

![](http://i.imgur.com/8JdxCON.gif)


> Note: `bishop` is just the name of my Tessel 2 board, yours will display whatever you've named your board!

**Bonus:** EXTRA CHALLENGE FOR VIDEO
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a plan for this?


To see what else you can do with the USB camera module, read the [tessel-av](https://github.com/tessel-av) documentation.

- Try connecting a button to your Tessel 2 and use it as a shutter.
- Use an USB storage drive to store many photos.



</div>
<div class="large-6 columns">

![](http://i.imgur.com/Yjvr1Uc.png)

</div>
</div>

<div class="row">
<div class="large-12 columns">

### Step 6

What else can you do with a camera module? Get inspired by a [community-created project.](http://tessel.io/projects)


What are you making? [Share your invention!](//tessel.io/projects)

If you run into any issues you can check out the [module forums](http://forums.tessel.io/c/modules).

</div>
</div>