Community
cancel
Showing results for 
Search instead for 
Did you mean: 
KJiso
Novice
1,698 Views

contrilling cam with switch

*please understand for my low english ability

Hello everyone. I'm a Korean student.

I want to make something with intel edison for my graduation task.

the problem is

-> i want to control cam with switch

example : switch value = 1 : video streaming on

switch value = 0 : video streaming off

i read the contents about video streaming on intel edison(with mjpg-streamer) but i can't control on/off status

my friend suggest me to control sh with mraa

but i'm not sure it is possible

i hope you to give me some nice tip. thank you.

5 Replies
idata
Community Manager
30 Views

Hi,

 

 

Take a look at this: https://github.com/drejkim/edi-cam https://github.com/drejkim/edi-cam. This is a step by step tutorial for get a live video streaming on Intel Edison. I suggest you to run this tutorial first and check how responds your camera with your Edison.

 

Once that you have been able to run the code and see the video streaming on your web browser, I think a good approach will be reading the digital pin connected to the switch, with this you can create a code that will run the server.js only when the pin is high or low.

 

If you want to use the microswitch on the Arduino Expansion Board I suggest you to run a bash script that runs the command lsusb to verify the position of the microswitch.

 

 

Regards,

 

Charlie
KJiso
Novice
30 Views

Hello Charlie.

I appreciate for your kindness.

In fact, i already read that post(edi-cam) and complete the video streaming.

I also created the code and implement by running node.js

but i still don't know how to control the status of cam.

i can turn on or off the streaming the cam by typing the instruction(through serial or wi-fi connection) but i can't do this by state of switch.

unfortunately we can't use arduino expansion board because we are planning to make a wearable device(arduino board is too big to use.)

I don't have a alternative method so i think i have to study and approach by other way.

thank for your kindness again.

Regards,

Jisoo

idata
Community Manager
30 Views

Hi Jisoo,

I suggest you to check the MRAA library: http://iotdk.intel.com/docs/master/mraa/ http://iotdk.intel.com/docs/master/mraa/ specifically the GPIO>ISR (http://iotdk.intel.com/docs/master/mraa/gpio_8h.html# a61e3a45eb7daad362af4a116d01111fa http://iotdk.intel.com/docs/master/mraa/gpio_8h.html# a61e3a45eb7daad362af4a116d01111fa) This will allow you to see the change of the state in the pins you are using on the code, take a look at the example https://github.com/intel-iot-devkit/mraa/blob/master/examples/python/hello_isr.py https://github.com/intel-iot-devkit/mraa/blob/master/examples/python/hello_isr.py (for python), there is also an example for JS (https://github.com/intel-iot-devkit/mraa/blob/master/examples/javascript/isr.js https://github.com/intel-iot-devkit/mraa/blob/master/examples/javascript/isr.js).

Once that your code have detected a change in the pin (your switch) you can use a system call and run the server.

 

http://rosettacode.org/wiki/Execute_a_system_command# Python http://rosettacode.org/wiki/Execute_a_system_command# Python

 

http://rosettacode.org/wiki/Execute_a_system_command# JavaScript http://rosettacode.org/wiki/Execute_a_system_command# JavaScript

You can also use an if instance but you have to check that the system call is not being executed over and over again. For example with a code like:

import mraa

 

import time

 

import os

x = mraa.Gpio(8)

 

y = mraa.Gpio(13)

x.dir(mraa.DIR_IN)

 

y.dir(mraa.DIR_OUT)

while True:

 

if x.read() == 1:

 

y.write(1)

 

exit_code = os.system('node /home/root/edi-cam/web/server/server.js')

 

else:

 

y.write(0)

The system call is inside of the While loop, even if the code is detecting when the 8 pin is high or low it will run the server over and over again and this will not work.

 

I hope this gives you an idea on how to continue with your project.

Regards,

 

Charlie

 

KJiso
Novice
30 Views

Dear Charlie.

I can't try this right now because i'm in far place from school.

but i think your tip is correct answer. i really thank you.

Due to my low English and engineering skills, i couldn't find correct way to prove this problem.

but you gave me a lot information and tip.now, i think i can solve this problem(Thank for your tip)

again, i really thank you. I pray for your happiness.

your student Jisoo.

idata
Community Manager
30 Views

Hi Jisoo,

 

 

Thank you very much! I hope the best for you too. If you are able to work on this in the future and you have more questions/doubts, don't hesitate to contact us again and/or to open a new thread, we will be glad to help you.

 

 

Regards,

 

Charlie