xephos
Posts: 7
Joined: Sun Apr 22, 2018 6:29 pm

Acclerometer, Processing and Python

Sun Apr 29, 2018 7:23 pm

Hi I have a Pi with acclerometer set up and functioning.

The issue i'm trying to solve is that I want the Rasp Pi to play videos, and for the acclerometer to control that.

So for example if I have a set of 5 videos.If the device (Pi) with the acclerometer is tilted left it would play video 1 and of it was titled right it would play video 2.

I have tested the acclerometer in Python , made the videos, and I an idea of what kind of code I could use the get this feature running, and after I get the code to set up a serial communication between Python and Processing.

I am a complete newb to pi/coding in general.

nios2
Posts: 38
Joined: Mon Mar 12, 2018 3:22 am

Re: Acclerometer, Processing and Python

Mon Apr 30, 2018 9:06 am

There does not appear to be a question in your post.

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: Acclerometer, Processing and Python

Mon Apr 30, 2018 9:46 am

xephos wrote:with the acclerometer is tilted left it would play video 1 and of it was titled right it would play video 2.
I have tested the acclerometer in Python , made the videos, and I an idea of what kind of code I could use the get this feature running
possibly you look for this kind of code

Code: Select all

#!/usr/bin/env python3
# test start omx video player from python
import subprocess
print("try start OMX player")
subprocess.call(['omxplayer','--win','100,100,560,420','/opt/vc/src/hello_pi/hello_video/test.h264'])

should run as is on any RASPBIAN Desktop like from terminal:
nano py3_omx_start.py
chmod +x py3_omx_start.py
./py3_omx_start.py
try start OMX player
Video codec omx-h264 width 1920 height 1080 profile 77 fps 25.000000
Subtitle count: 0, state: off, index: 1, delay: 0
V:PortSettingsChanged: [email protected] interlace:0 deinterlace:0 anaglyph:0 par:1.00 display:0 layer:0 alpha:255 aspectMode:0
have a nice day ;)
Image

xephos
Posts: 7
Joined: Sun Apr 22, 2018 6:29 pm

Re: Acclerometer, Processing and Python

Thu May 10, 2018 2:39 pm

nios2 wrote:
Mon Apr 30, 2018 9:06 am
There does not appear to be a question in your post.
I would want to control which video is played on the pi with the acclerometer, and find a way to go about that.

xephos
Posts: 7
Joined: Sun Apr 22, 2018 6:29 pm

Re: Acclerometer, Processing and Python

Thu May 10, 2018 2:41 pm

KLL wrote:
Mon Apr 30, 2018 9:46 am
xephos wrote:with the acclerometer is tilted left it would play video 1 and of it was titled right it would play video 2.
I have tested the acclerometer in Python , made the videos, and I an idea of what kind of code I could use the get this feature running
possibly you look for this kind of code

Code: Select all

#!/usr/bin/env python3
# test start omx video player from python
import subprocess
print("try start OMX player")
subprocess.call(['omxplayer','--win','100,100,560,420','/opt/vc/src/hello_pi/hello_video/test.h264'])

should run as is on any RASPBIAN Desktop like from terminal:
nano py3_omx_start.py
chmod +x py3_omx_start.py
./py3_omx_start.py
try start OMX player
Video codec omx-h264 width 1920 height 1080 profile 77 fps 25.000000
Subtitle count: 0, state: off, index: 1, delay: 0
V:PortSettingsChanged: [email protected] interlace:0 deinterlace:0 anaglyph:0 par:1.00 display:0 layer:0 alpha:255 aspectMode:0
have a nice day ;)
Image
Thanks, for the info. Would I be able to control the video player with the accelerometer using this?

User avatar
bensimmo
Posts: 4187
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Acclerometer, Processing and Python

Thu May 10, 2018 4:22 pm

Are you suggesting, making a Python (or other program) to act as a menu to launch some videos.?

Which parts do you have working?

- Using the the accelerometer as a selector (joystick/arrow keys)
So you can print out which video you would like to launch.
You could look for the 'g' rating, polling with if,elseif,...
Or setup Events on something happening.



-launching a video (as given above)

-Replacing the prints in the selector, with the launching of the video.


I don't know what 'processing' has to do with this (or what it really does).

xephos
Posts: 7
Joined: Sun Apr 22, 2018 6:29 pm

Re: Acclerometer, Processing and Python

Thu May 10, 2018 7:04 pm

bensimmo wrote:
Thu May 10, 2018 4:22 pm
Are you suggesting, making a Python (or other program) to act as a menu to launch some videos.?

Which parts do you have working?

- Using the the accelerometer as a selector (joystick/arrow keys)
So you can print out which video you would like to launch.
You could look for the 'g' rating, polling with if,elseif,...
Or setup Events on something happening.



-launching a video (as given above)

-Replacing the prints in the selector, with the launching of the video.


I don't know what 'processing' has to do with this (or what it really does).
I did not know that python could play video , so i was going to use processing the video. I'm very new so my workflow is going to be all over the place. Processing is a software that mainly deals with coding media, like images, to do various things.

I have gotten the acclerometer interfaced and tested that its working with media. Here is a video of me using the Python game to control a teapot with the acclerometer.

https://youtu.be/Qz6EJ7XX7bE


In layman's terms I want to have a way to load a bunch of video with a suitable program and then control which video is played by moving the acclerometer.

I appreciate you lot's help and patience with me, I'm just trying to figure this out.

Return to “Beginners”