Category Archives: RaspberryPi

Python + openCV + video

The purpose here is to play video in rPi using python + openCv. However, the avi file i call do not load as expected. I stripped off all the other code pieces, and focus on the loading to cheack what is wrong: and it printed False, which means it cant read my video format a quick google brought me here. I will need to download mplayer first and use the memcoder in it to convert the format. and now, it runs perfectly The complete code to play video:  

Boot-up rPi screen by 90 rotation

My monitor allow me to rotate it 90degree into vertical pos, which is good for my web design usage. In ubuntu, i can install a gui app and it allow me to rotate the screen easily with similar experience on windows system. However, rPi do not have a bios, so the way to do it is to edit /boot/config.txt Then, add in this line at the bottom of the file if it is not exists yet: Refer here for more info.

My First rPi Experience

Bought over a raspberry pi model B (quite an old model) from a friend and started my journey venture into this platform. With a background from Arduino, I manage to pick it up without much troubles. 20141013_225759
  1. rPi is a much more powerful single board computer than Arduino UNO. It run real OS – linux.
  2. There is no HDD but only SD card as storage.
  3. The default login, username: pi, password: raspberry
  4. If you cant see your favourite GUI, type startx in terminal, after-all it is linux.
  5. In Arduino, you write in Arduino IDE; In rPi, you write using any programming language, but most popular one is python.
  6. In Arduino, it’s Input/Output pin; In rPi, you got GPIO
  7. You can light an IDE using command line! Refer Here
  8. For prototyping on breadboard, You need something extra, can be purchase here
  9. You need to have Internet access. i am using a wifi in this case.
  10. Your python wont work out of the box with GPIO, follow instruction here to setup
  11. Then, you may follow this tutorial to blink an LED
  12. In case you cant type # correctly (fucking important for programmer) in rPi due to stupid mapping to UK keyboard by default. try Ctl+Alt+3 (but only work in idle) as describe here or better, follow the answer here to change XKBLAYOUT from uk to us
Ok, here is some additional note about running python scripts, you may ignore this if you already familiar with linux:
  1. You can always start idle in sudo mode, open the file yourfilename.py and hit F5
  2. you can always type command in terminal, python ./yourfilename.py. Remember to chmod +x  the file first to make it executable (some extra step that linux have compare to windows).
  3. or.. you can prepend this line #!/usr/bin/env python in yourfilename.py. Then, you can start it in terminal straight away without calling thru python: ./yourfilename.py