Wednesday, September 30, 2015

Install gPhoto and libgphoto2 2 2.5.4 on Raspberry Pi 2/Raspbian-Jessie using apt-get

The new Raspbian Jessie apt-get repository now provide gPhoto2 and libgphoto2 version 2.5.4 (not the latest 2.5.8). If you accept, you can install it with command line:
$ sudo apt-get install gphoto2

This video show how to, and also show testing in command line.



If you prefer the latest gPhoto2 2.5.8, you can Compile it with gphoto2-updater script.

Tuesday, September 29, 2015

Raspbian Jessie saved my defected Raspberry Pi 2

As I mentioned long time ago, My Raspberry Pi 2 cannot detect monitor resolution!!! It always set default resolution of 640x480. (It should be the first batch of RS version) That's why I have to bought second raspberry Pi 2.

Today I test new Raspbian Jessie on the defected Raspberry Pi 2, unexpectedly it can recognize the correct resolution.

Here is the same Raspberry Pi 2 running Raspbian Jessie (32G Ultra Class-10 micro-SD) vs Raspbian Wheezy (16G Class-4 micro-SD).

1440x900 detected in Raspbian Jessie

640x480 detected in Raspbian Wheezy

First boot Raspbian Jessie on Raspberry Pi 2

First boot Raspbian Jessie (2015-09-24) on Raspberry Pi 2:


Now the RPi boot-up in GUI mode directly, you can access Raspberry Pi Configuration GUI with:
> Menu > Preferences > Raspberry Pi Configuration


You can now press [PrtSc] to capture screen.

~ More posts replated to new Raspbian Jessie.


Raspbian Jessie - major Raspberry Pi official OS upgrade

It is a major version upgrade – from Raspbian Wheezy to Raspbian Jessie, with large number of changes to the underlying operating system.

Download HERE.

To know more about Raspbian Jessie, visit Raspberry Pi Blog.

Related to Raspbian Jessie:
- First boot Raspbian Jessie on Raspberry Pi 2.


- Bonus: Raspbian Jessie saved my defected Raspberry Pi 2
- gPhoto2 and GtKam, Raspbian Jessie apt-get repository now provide install gPhoto2 2.5.4 and GtKam 0.2.0.
Remote run JavaFX on Raspbian Jessie, from Netbeans/Windows 10.


On raspberry Pi 1:

I tried to install Raspbian Jessie on Raspberry Pi 1, but the menu bar disappeared!

Raspbian Jessie on Raspberry Pi 1
Raspbian Jessie on Raspberry Pi 1 - remote login using Windows' Remote Desktop Connection and xrdp on Raspberry Pi

Monday, September 28, 2015

Install and run GtKam on Raspberry Pi 2


gtkam is a graphical front end for the gphoto2 library. It does not communicate directly with the camera, but uses gphoto2 to do so. As a result, it is necessary to have gphoto2 installed and running correctly before gtkam will work.

This video show how I install and run GtKam on Raspberry Pi 2, connect and remote control Nikon DSLR D7000, and capture photos.


In this video, I install the current Raspbian supported package gtkam 0.1.18-1, not the latest version.

Once you plug in and power on your camera (D7000 in my case), you have to unmount it before GtKam/gPhoto2 connect it, otherwise it will fail with error of  "Could not initialize camera".

With GtKam run properly, you can view camera's photos, capture photos, and save photos to RPi local storage...but may be too slow:(

reference: Quick start - Using gtkam


Updated@2015-09-30: 
The NEW Raspbian Jessie provide apt-get gtkam 0.2.0, the latest version.

Test gPhoto2 2.5.8 on Raspberry Pi 2 + Nikon D7000 DSLR, in command line


Last post show how to easy compile and install gPhoto2 2.5.8 on Raspberry Pi 2/Raspbian with gphoto2-updater script. This video show testing installed gPhoto2 on command line, with Nikon D7000 DSLR connected to RPi 2 with USB.


reference: The gPhoto2 Manual - Using the gphoto2 command line interface (CLI)

Next:
Install and run GtKam on Raspberry Pi 2

Sunday, September 27, 2015

Compile and install gPhoto2 2.5.8 and libgphoto2 for Raspberry Pi, with gphoto2-updater script

gPhoto2 is a free, redistributable, ready to use set of digital camera software applications for Unix-like systems.

It can be installed on Raspberry Pi with:
$ sudo apt-get install gphoto2

But it's version 2.4.14-1, not the latest version 2.5.8.

gphoto2-updater is a compiler and installer script specifically created for Raspbian and Raspberry Pi, but should work over any Debian-based distribution. It support the latest version 2.5.8 currently.


To download and compile last script version just be sure you are connected to the Internet and run:
$ wget https://raw.githubusercontent.com/gonzalo/gphoto2-updater/master/gphoto2-updater.sh && chmod +x gphoto2-updater.sh && sudo ./gphoto2-updater.sh


This video show running the script on Raspberry Pi 2/Raspberry Wheezy to compile and install gphoto2 2.5.8 in 46min.


Condition:
- Board: Raspberry Pi 2 (RS version)
- OS: Raspbian Wheezy 2015-05-05
- SD: Class-4 (slow)
- Connection: WiFi
- Remote control from Windows 10 running PuTTY SSH

Next:
- Test gPhoto2 2.5.8 on Raspberry Pi 2 + Nikon D7000 DSLR, in command line
Install and run GtKam on Raspberry Pi 2



Updated@2015-09-30:
This video show running the script on Raspberry Pi 2/NEW Raspbian Jessie to compile and install gphoto2 2.5.8 in 23min.

After finished, the gPhoto2 is version 2.5.8, but libgphoto2 is 2.5.4!!!


Condition:
- Board: Raspberry Pi 2 (Element-14 version)
- OS: Raspbian Jessie 2015-09-24
- SD: Class-10 Ultra (fast)
- Connection: Cable
- Remote control from Windows 10 Remote Desktop Connection to Raspberry Pi XDP

[Remark]
Just for reference. It's NOT aim to compare the performance between Raspbian Wheezy and Jessie. The two setup in difference configuration.

Updated again@2015-12-02:
To install both gphoto2 and libphoto2 2.5.9, refer "Install gphoto2 and libgphoto2 version 2.5.9 on Raspberry Pi 2/Raspbian Jessie 2015-11-21".


python-gphoto2 related:
- Install python-gphoto2 on Raspberry Pi 2/Raspbian Jessie - fail
- Install python-gphoto2 on Raspberry Pi 1/Raspbian Wheezy - success

Search for available package, and know the version before install

apt-cache is a low-level tool used to query information from APT's binary cache files.


You can search available package with"
$ apt-cache search package


or know the details of the package; such as version
$ apt-cache show package


Capture Raspberry Pi Camera image, display on OpenCV, Matplotlib PyPlot and Tkinter GUI

This example capture photo from Raspberry Pi Camera Module, and display with OpenCV, Matplotlib PyPlot and Tkinter GUI.


usage:
python pyCV_picam.py 1 - display wiyh OpenCV window
python pyCV_picam.py 2 - display with matplotlib
python pyCV_picam.py 3 - display with Tkinter

import picamera
import picamera.array
import time
import cv2
from matplotlib import pyplot as plt
import Tkinter 
import Image, ImageTk
import sys

def capturePiCam():
    with picamera.PiCamera() as camera:
        cap=picamera.array.PiRGBArray(camera)
        camera.resolution = (640, 480)
        camera.start_preview()
        time.sleep(3)
        camera.capture(cap,format="bgr")
        global img
        img =cap.array

#- display on OpenCV window -
def displayAtOpenCV():
    cv2.namedWindow('imageWindow', cv2.WINDOW_AUTOSIZE)
    cv2.imshow('imageWindow',img)
    cv2.waitKey(0)
    cv2.destroyAllWindows()

#- display with matplotlib -
def displayAtPyplot():
    plt.figure().canvas.set_window_title("Hello Raspberry Pi")
    plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
    plt.xticks([]), plt.yticks([])  # to hide tick values on X and Y axis
    plt.show()
    
#- display on Tkinter -
def displayAtThinter():
    root = Tkinter.Tk() 
    b,g,r = cv2.split(img) 
    img2 = cv2.merge((r,g,b))
    img2FromArray = Image.fromarray(img2)
    imgtk = ImageTk.PhotoImage(image=img2FromArray) 
    Tkinter.Label(root, image=imgtk).pack() 
    root.mainloop()

def displayUsage():
    print("usage: ")
    print("python pyCV_picam.py 1 - display wiyh OpenCV window")
    print("python pyCV_picam.py 2 - display with matplotlib")
    print("python pyCV_picam.py 3 - display with Tkinter")

if len(sys.argv) != 2:
    displayUsage()
    sys.exit()
    
opt = sys.argv[1]

if opt=="1":
    print("display wiyh OpenCV window")
    capturePiCam()
    displayAtOpenCV()
elif opt=="2":
    print("display with matplotlib")
    capturePiCam()
    displayAtPyplot()
elif opt=="3":
    print("display with Tkinter")
    capturePiCam()
    displayAtThinter()
else:
    displayUsage()
    



To use ImageTk in your python, refer to "Install PIL (with jpg supported) and ImageTk on Raspberry Pi/Raspbian".

Install PIL (with jpg supported) and ImageTk on Raspberry Pi/Raspbian


To install PIL (with jpg supported) and ImageTk on Raspberry Pi/Raspbian, to display jpg on Python/Tkinter GUI.

$ sudo apt-get install libjpeg8-dev

Then find libjpeg.so and create link on /usr/lib/
$ find /usr/lib -name libjpeg.so
/usr/lib/arm-linux-gnueabihf/libjpeg.so
$ sudo ln -s /usr/lib/arm-linux-gnueabihf/libjpeg.so /usr/lib/

Then install PIL and python-imaging-tk
$ sudo apt-get install python-pip
$ sudo pip install PIL


If you reported with error like this:

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DHAVE_LIBJPEG -IlibImaging -I/usr/include -I/usr/local/include -I/usr/include/python2.7 -c _imaging.c -o build/temp.linux-armv7l-2.7/_imaging.o

_imaging.c:75:20: fatal error: Python.h: No such file or directory

compilation terminated.

error: command 'gcc' failed with exit status 1
----------------------------------------

Install python-dev:
$ sudo apt-get install python-dev

and re-run the command:
$ sudo pip install PIL


$ sudo apt-get install python-imaging-tk


Updated@2015-12-16 for Jessie:
Tested on Raspberry Pi 2 running Raspbian Jessie 2015-11-21, no need install PIL, but still have to install python-imaging-tk.

Saturday, September 26, 2015

Python capture picamera image, display on OpenCV and matplotlib


Python example to capture image from Raspberry Pi Camera Module with picamera, display on OpenCV and matplotlib.

This demo run on Windows log-in Raspberry Pi 2/Raspbian remotely, so the preview will not shown.


pyCV_picam.py
import picamera
import picamera.array
import time
import cv2
from matplotlib import pyplot as plt

with picamera.PiCamera() as camera:
    cap=picamera.array.PiRGBArray(camera)
    camera.resolution = (640, 480)
    camera.start_preview()
    time.sleep(3)
    camera.capture(cap,format="bgr")
    img=cap.array
    
#- display on OpenCV window -
cv2.namedWindow('imageWindow', cv2.WINDOW_AUTOSIZE)
cv2.imshow('imageWindow',img)
cv2.waitKey(0)
cv2.destroyAllWindows()

#- display with matplotlib
#plt.figure().canvas.set_window_title("Hello Raspberry Pi")
#plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
#plt.xticks([]), plt.yticks([])  # to hide tick values on X and Y axis
#plt.show()




more:
~ Display on Tkinter GUI also.

Raspberry Pi + Python/OpenCV, draw something on OpenCV image


Example to draw something on OpenCV image.


pyCV_draw.py
import platform
import os
import sys
import cv2
import numpy
import urllib
import matplotlib
from matplotlib import pyplot as plt

print platform.system(), platform.release(), platform.dist()
print os.uname()
print("Python version: \n" + sys.version)
print("cv2 version: " + cv2.__version__)
print("numpy version: " + numpy.__version__)
print("urllib version: " + urllib.__version__)
print("matplotlib version: " + matplotlib.__version__)

#- load image from local file
#img = cv2.imread('test.png', cv2.IMREAD_UNCHANGED)

#- load image from internet
url = 'http://goo.gl/41cgQr'
data = urllib.urlopen(url)
img = numpy.asarray(bytearray(data.read()), dtype='uint8')
img = cv2.imdecode(img, cv2.IMREAD_COLOR)

#draw something
#ref: 
#http://docs.opencv.org/master/dc/da5/tutorial_py_drawing_functions.html
cv2.line(img,(0,0),(511,511),(255,0,0),5)
cv2.rectangle(img,(384,0),(510,128),(0,255,0),3)
cv2.circle(img,(447,63), 63, (0,0,255), -1)
cv2.ellipse(img,(256,256),(100,50),0,0,180,255,-1)
pts = numpy.array([[10,5],[20,30],[70,20],[50,10]], numpy.int32)
pts = pts.reshape((-1,1,2))
cv2.polylines(img,[pts],True,(0,255,255))
font = cv2.FONT_HERSHEY_SIMPLEX
# AttributeError: 'module' object has no attribute 'LINE_AA'
# to solve it, change 'LINE_AA' to 'CV_AA'
#cv2.putText(img,'OpenCV',(10,500), font, 4,(255,255,255),2,cv2.LINE_AA)
cv2.putText(img,'OpenCV',(10,500), font, 4,(255,255,255),2,cv2.CV_AA)

#- display on OpenCV window -
#cv2.namedWindow('imageWindow', cv2.WINDOW_AUTOSIZE)
#cv2.imshow('imageWindow', img)
#cv2.waitKey(0)
#cv2.destroyWindow('imageWindow')

#sys.exit()

#- display with matplotlib
#set window title of matplotlib plt
plt.figure().canvas.set_window_title("Hello Raspberry Pi") 
#-- incorrect color
#plt.imshow(img, cmap = 'gray', interpolation = 'bicubic')
#-- correct color with cv2.cvtColor()
plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
plt.xticks([]), plt.yticks([])  # to hide tick values on X and Y axis
plt.title("Hello Raspberry Pi")
plt.suptitle("http://helloraspberrypi.blogspot.com/")

plt.show()


Friday, September 25, 2015

Python control Raspberry Pi 2 PWR/ACT LED, using RPi.GPIO or system's shell.

Last post show how to "Control Raspberry Pi 2 B on-board ACT LED with Python/RPi.GPIO", this example show how to control both the PWR and ACT LED of Raspberrry Pi 2 B, using Python, with RPi.GPIO and via system's shell by calling os.system().


*Please note that it's for Raspberrry Pi 2 B only*

Refer to Windows IoT document Raspberry Pi 2 Pin Mappings:
Red Power LED's GPIO# is 35.
Green Activity LED's GPIO# is 47.

In my experience, it cannot be perform using sudo, you have to login as root. To login as root, refer to the post "Set password of root".

pyGPIO.py
import sys
import os
import RPi.GPIO as GPIO
import time

print("**********************************************")
print("*** Toggle PWR/ACT LED on Raspberry Pi 2 B ***")
print("***        for Raspberry Pi 2 B only       ***")
print("**********************************************")
print("- System info -")
print(sys.version)
print("GPIO.VERSION: " + GPIO.VERSION)
print("GPIO.RPI_REVISION (deprecated): " + str(GPIO.RPI_REVISION))

print("")
print("GPIO.RPI_INFO:")
print(GPIO.RPI_INFO)

print("")
for keys,values in GPIO.RPI_INFO.items():
 print(keys + " : " + str(values))

print("")
#display trigger for led0 and led1
print("- Original trigger for led 0 -")
os.system("cat /sys/class/leds/led0/trigger")
print("- Original trigger for led 1 -")
os.system("cat /sys/class/leds/led1/trigger")

print("remove the trigger for led0 and led1")
os.system("echo none >/sys/class/leds/led0/trigger")
os.system("echo none >/sys/class/leds/led1/trigger")
os.system("cat /sys/class/leds/led0/trigger")
os.system("cat /sys/class/leds/led1/trigger")
print("")
 
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(35, GPIO.OUT) #Red PWR LED on RPi2B 
GPIO.setup(47, GPIO.OUT) #Green Activity LED on RPi2B

for num in range(1, 5):
    print num
    
    #Control led0 with RPi.GPIO
    GPIO.output(47, False)  #Turn OFF ACT LED for RPi 2 B
    GPIO.output(35, True) #Turn ON PWR LED for RPi 2 B
    print "LED PWR(RED)-ON ACT(GREEN)-OFF"
    time.sleep(2)

    #Control led1 with system's shell
    os.system("echo 1 >/sys/class/leds/led0/brightness")
    os.system("echo 0 >/sys/class/leds/led1/brightness")
    print "LED PWR(RED)-OFF ACT(GREEN)-ON"
    time.sleep(3)

print("")
print("Finished")
#rsume the trigger for led0 and 
#assume it's mmc0 and input
os.system("echo mmc0 >/sys/class/leds/led0/trigger")
os.system("echo input >/sys/class/leds/led1/trigger")

print("- Resummed trigger for led 0 -")
os.system("cat /sys/class/leds/led0/trigger")
print("- Resummed trigger for led 1 -")
os.system("cat /sys/class/leds/led1/trigger")
print("")


Thursday, September 24, 2015

Python/RPi.GPIO Control Raspberry Pi 2 B on-board ACT LED

I have a old example "Control the on-board LED using Python" to toggle Raspberry Pi 1 ACT LED. It's updated to toggle the ACT LED on Raspberry Pi 2.


On Raspberry Pi 2 B, the ACT LED is assigned pin 47.

pyGPIO.py
import sys
import RPi.GPIO as GPIO
import time

print(sys.version)
print("GPIO.VERSION: " + GPIO.VERSION)
print("GPIO.RPI_REVISION (deprecated): " + str(GPIO.RPI_REVISION))

print("")
print("GPIO.RPI_INFO:")
print(GPIO.RPI_INFO)

print("")
for keys,values in GPIO.RPI_INFO.items():
 print(keys + " : " + str(values))
 
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
#GPIO.setup(16, GPIO.OUT)
GPIO.setup(47, GPIO.OUT)

for num in range(1, 5):
    print num
    #GPIO.output(16, True)   ##Turn OFF LED
    GPIO.output(47, False)   ##Turn OFF LED for RPi 2 B
    print "LED OFF"
    time.sleep(2)
    #GPIO.output(16, False) ##Turn ON LED
    GPIO.output(47, True)   ##Turn ON LED for RPi 2 B
    print "LED ON"
    time.sleep(3)

#GPIO.output(16, True)   ##Turn OFF LED
GPIO.output(47, False)   ##Turn OFF LED for RPi 2 B


In my experience, it cannot be perform using sudo, you have to login as root. To login as root, refer to the post "Set password of root".

Then login as root.

by default, the ACT LED is set triggered by mmc0. It can be checked with the command:

# cat /sys/class/leds/led0/trigger
none [mmc0] timer oneshot heartbeat backlight gpio cpu0 default-on

In order to program it as GPIO, remove the trigger with the command:
# echo none >/sys/class/leds/led0/trigger

Run our Python example, pyGPIO.py
# python pyGPIO.py

After test, resume the trigger by mmc0 with command (or reboot):
# echo mmc0 >/sys/class/leds/led0/trigger


Next:
- Python control Raspberry Pi 2 PWR/ACT LED, using RPi.GPIO or system's shell.

Win a Halloween Raspberry Pi Kit


element14 community have decided to give away 10 Pi Sense Hats and 7-inch Pi Touchscreens along with other goodies for you to Build-A-Long with two awesome Halloween projects.

details ~ Enter to Win a Pi Sense Hat or Pi Touchscreen 7.0


Wednesday, September 23, 2015

Raspberry Pi + Python/OpenCV, display image on matplotlib pyplot


With OpenCV image displayed using matplotlib pyplot, we can resize the window, also save the image on storage. This Python example run on Raspberry Pi 2, show how to load JPG image from internet, display on pyplot, save to local storage in PNG format, then open and display the saved local image.


import platform
import os
import sys
import cv2
import numpy
import urllib
import matplotlib
from matplotlib import pyplot as plt

print platform.system(), platform.release(), platform.dist()
print os.uname()
print("Python version: \n" + sys.version)
print("cv2 version: " + cv2.__version__)
print("numpy version: " + numpy.__version__)
print("urllib version: " + urllib.__version__)
print("matplotlib version: " + matplotlib.__version__)

#- load image from local file
#img = cv2.imread('test.png', cv2.IMREAD_UNCHANGED)

#- load image from internet
url = 'http://goo.gl/41cgQr'
data = urllib.urlopen(url)
img = numpy.asarray(bytearray(data.read()), dtype='uint8')
img = cv2.imdecode(img, cv2.IMREAD_COLOR)

#- display on OpenCV window -
#cv2.namedWindow('imageWindow', cv2.WINDOW_AUTOSIZE)
#cv2.imshow('imageWindow', img)
#cv2.waitKey(0)
#cv2.destroyWindow('imageWindow')

#- display with matplotlib
#set window title of matplotlib plt
plt.figure().canvas.set_window_title("Hello Raspberry Pi") 
#-- incorrect color
#plt.imshow(img, cmap = 'gray', interpolation = 'bicubic')
#-- correct color with cv2.cvtColor()
plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
plt.xticks([]), plt.yticks([])  # to hide tick values on X and Y axis
plt.title("Hello Raspberry Pi")
plt.suptitle("http://helloraspberrypi.blogspot.com/")

plt.show()

~ To use matplotlib with Python 2 on Raspberry Pi, refer "Install numpy, matplotlib and drawnow for Python 2".

Tuesday, September 22, 2015

Raspberry Pi + Python/OpenCV, show image in window

To creates window in Python/OpenCV, call:
cv2.namedWindow('imageWindow', cv2.WINDOW_AUTOSIZE)


Here is a Python example using OpenCV to load image from internet, display in window.
import sys
import cv2
import numpy
import urllib

print("Python version: \n" + sys.version)
print("cv2 version: " + cv2.__version__)
print("numpy version: " + numpy.__version__)
print("urllib version: " + urllib.__version__)

url = 'http://goo.gl/41cgQr'
data = urllib.urlopen(url)
img = numpy.asarray(bytearray(data.read()), dtype='uint8')
img = cv2.imdecode(img, cv2.IMREAD_COLOR)
cv2.namedWindow('imageWindow', cv2.WINDOW_AUTOSIZE)
cv2.imshow('imageWindow', img)
cv2.waitKey(0)
cv2.destroyWindow('imageWindow')

Raspberry Pi + Python/OpenCV, load image from internet


Python example on Raspberry Pi to load image from internet, using OpenCV:
import sys
import cv2
import numpy
import urllib

print("Python version: \n" + sys.version)
print("cv2 version: " + cv2.__version__)
print("numpy version: " + numpy.__version__)
print("urllib version: " + urllib.__version__)

url = 'http://goo.gl/41cgQr'
data = urllib.urlopen(url)
img = numpy.asarray(bytearray(data.read()), dtype='uint8')
img = cv2.imdecode(img, cv2.IMREAD_COLOR)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyWindow('image')



Easy copy files between Raspberry and Windows, FileZilla Client


To copy files between Raspberry and Windows, FileZilla Client is suggested. FileZilla is a cross-platform graphical FTP, SFTP, and FTPS file management tool for Windows, Linux, Mac OS X, and more. With tons of intuitive tools, FileZilla helps you quickly move files between your computer and Web server (and also Raspberry Pi).

To transfer files between Windows and Raspberry Pi, FileZilla Client is needed to be installed on Windows. This video show how to download and install FileZilla Client, setup site for Raspberry Pi using SFTP - SSH protocol, and transfer file.

to Download FileZilla, visit: https://filezilla-project.org/

Raspberry Pi + Python/OpenCV, load and display image


Example of Python run on Raspberry Pi 2 to load and display image using OpenCV 2:
import sys
import cv2

print("Python version: \n" + sys.version)
print("cv2 version: " + cv2.__version__)

img = cv2.imread('smallRPi.JPG', cv2.IMREAD_UNCHANGED)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyWindow('image')




Sunday, September 20, 2015

Intro to Development and Deploying Applications to Windows IoT Core on Raspberry Pi 2

In this video we will go over deploying apps through Visual Studio and the web portal running on port 8080 of the Raspberry Pi2,  In addition, we will look at code examples using XAML User Interface code in both C# and C++.
source: https://channel9.msdn.com/Blogs/WinCoder/Intro-to-Development-and-Deploying-Applications-to-Windows-IoT-Core-on-Raspberry-Pi-2



Related: Setup Windows 10 IoT Core on Windows 10 and Raspberry Pi 2

Setup Windows 10 IoT Core on Windows 10 and Raspberry Pi 2

This videos show how to:
  • Install the Windows 10 IoT Core tools on Windows 10
  • Flash Windows 10 IoT Core image on micro-SD
  • Boot-up Windows 10 IoT Core on Raspberry Pi 2
  • Install Windows IoT Core Project Templates for Visual Studio 2015 

- Install the Windows 10 IoT Core tools on Windows 10


- Flash Windows 10 IoT Core image on micro-SD
* Advised use micro-SD of class 10, I tried class 4 but fail in boot-up.


- Boot-up Windows 10 IoT Core on Raspberry Pi 2
* Advised to connect mouse also, to navigate in Windows 10 IoT Core/Raspberry Pi 2 windows.


reference: http://ms-iot.github.io/content/en-US/win10/SetupRPI.htm

- Install Windows IoT Core Project Templates for Visual Studio 2015, Install Windows IoT Core Project Templates for Visual Studio 2015, directly from Visual Studio in the Extension and Updates dialog (Tools - Extensions and Updates - Online).


reference: http://ms-iot.github.io/content/en-US/win10/SetupPCRPI.htm


Related: Intro to Development and Deploying Applications to Windows IoT Core on Raspberry Pi 2

Monday, September 14, 2015

Install OpenCV 2 on Raspberry Pi/Python 2


To install OpenCV 2 on Raspberry Pi, Python 2, enter the command in LXTerminal:
$ sudo apt-get install python-opencv


Install SciPy on Raspberry Pi


Install SciPy on Raspberry Pi, for Python 2, enter the command in LXTerminal
$ sudo apt-get install python-scipy

Install SciPy on Raspberry Pi, for Python 3
$ sudo apt-get install python3-scipy

Java example - scan connected IP in the same network

Last post advise use Advanced IP Scanner to scan connected host in the same network. Here is a Java example to scan connected IP in the same network, using isReachable(int timeout) method of java.net.InetAddress.


public boolean isReachable(int timeout) throws IOException

Test whether that address is reachable. Best effort is made by the implementation to try to reach the host, but firewalls and server configuration may block requests resulting in a unreachable status while some specific ports may be accessible. A typical implementation will use ICMP ECHO REQUESTs if the privilege can be obtained, otherwise it will try to establish a TCP connection on port 7 (Echo) of the destination host.

The timeout value, in milliseconds, indicates the maximum amount of time the try should take. If the operation times out before getting an answer, the host is deemed unreachable. A negative value will result in an IllegalArgumentException being thrown.


JavaIpScanner.java
package javaipscanner;

import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class JavaIpScanner {

    /*
    Example to scan ip 192.168.1.100~120
    check if any ip is reachable, means connected host
    */
    static final String SUB_NET = "192.168.1.";

    public static void main(String[] args) {
        scanHost(SUB_NET, 100, 120);
    }

    private static void scanHost(String subnet, int lower, int upper) {
        final int timeout = 3000;

        for (int i = lower; i <= upper; i++) {
            String host = subnet + i;
            try {
                InetAddress inetAddress = InetAddress.getByName(host);
                
                if (inetAddress.isReachable(timeout)){
                    System.out.println(inetAddress.getHostName() 
                            + " isReachable");
                    System.out.println(inetAddress.toString());
                    System.out.println("--------------------");
                }
                
            } catch (UnknownHostException ex) {
                Logger.getLogger(JavaIpScanner.class.getName())
                        .log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(JavaIpScanner.class.getName())
                        .log(Level.SEVERE, null, ex);
            }
        }
    }

}



Related:
- Android version Scan Reachable IP to discover devices in network

Find IP address of Raspberry Pi from Windows, use Advanced IP Scanner

Advanced IP Scanner is a free and fast network scanner allowing you to quickly retrieve information about network devices and get access to their various resources such as shared folders, HTTP, HTTPS, FTP, RDP and Radmin. The program does not require installation and has a simple and user-friendly interface. Advanced IP Scanner is widely used by system administrators and home users for network management and monitoring.

Advanced IP Scanner run on Windows 10 to find IP of Raspberry Pi


Related:
- Java example to find connected IPs in the same network


Thursday, September 10, 2015

Remote run Java on Raspberry Pi, host from NetBeans on Windows 10

This video show how to develop Java application with NetBeans IDE 8.0.2 running on Windows 10, create Remote Java SE platform, remote run/debug on Raspberry Pi/Raspbian Wheezy .




The following java code list system by calling System.getProperties().
package javaapplication14;

import java.util.Enumeration;
import java.util.Properties;

public class JavaApplication14 {

    public static void main(String[] args) {

        System.out.println("\nSystem Properties\n");
        System.out.println("=================\n");
        
        Properties properties = System.getProperties();
        System.out.println(properties.toString());
        System.out.println("\n");

        Enumeration<String> prop
                = (Enumeration<String>) properties.propertyNames();

        while (prop.hasMoreElements()) {
            String propName = prop.nextElement();
            System.out.println(
                    propName + " : "
                    + System.getProperty(propName));
        }
    }

}


How it run on Windows 10/Intel i5 vs Raspbian/Raspberry Pi 2.




Updated@2015-10-04: Appliable on Raspbian Jessie.

Tuesday, September 8, 2015

Windows 10 - how to find your WiFi IP and MAC address

To find your IP and MAC address in Windows 10:

- After WiFi connected. click on the WiFi icon on status bar, and click on "Network Settings"


- With NETWORK & INTERNET opened, and WiFi selected on left, scroll down.


- Click "Advanced options"


- Scroll down


- You can find your IP address in "IPv4 address", and MAC address in "Physical address".


The official Raspberry Pi 7" touch display released

The official Raspberry Pi touch display is on sale today (8th Sep 2015), priced at $60 (plus local taxes and shipping): you can buy it at the Swag Store, at RS Components/Allied Electronics and at Premier Farnell/Newark. Other sellers will be receiving stock later this week.


~ source: Raspberry Pi Blog: THE EAGERLY AWAITED RASPBERRY PI DISPLAY

Raspberry Pi 7" Touchscreen Display
The 7” Touchscreen Monitor for Raspberry Pi gives users the ability to create all-in-one, integrated projects such as tablets, infotainment systems and embedded projects. The 800 x 480 display connects via an adapter board which handles power and signal conversion. Only two connections to the Pi are required; power from the Pi’s GPIO port and a ribbon cable that connects to the DSI port present on all Raspberry Pi’s.  Touchscreen drivers with support for 10-finger touch and an on-screen keyboard will be integrated into the latest Raspbian OS for full functionality without a physical keyboard or mouse.

  • Turn your Raspberry Pi into a touch screen tablet, infotainment system, or standalone device.
  • Truly Interactive - the latest software drivers will support a virtual ‘on screen’ keyboard, so there is no need to plug in a keyboard and mouse.
  • Make your own ‘Internet of Things’ (IoT) devices including a visual display. Simply connect your Raspberry Pi, develop a Python script to interact with the display, and you’re ready to create your own home automation devices with touch screen capability.
  • A range of educational software and programs available on the Raspberry Pi will be touch enabled, making learning and programming easier on the Raspberry Pi.

Swag Store


Official Raspberry Pi DSI Display launches. Here is a full walkround with specifications and features. http://raspi.tv/?p=8513

Saturday, September 5, 2015

Remote Desktop Connection from Windows 10 to Raspberry Pi xrdp

This post show hoe to remote control Raspberry Pi from Windows 10, using Remote Desktop Connection.


In Raspberry Pi/Raspbian, install xrdp
$ sudo apt-get install xrdp


In Windows 10
- run Remote Desktop Connection
- Enter the IP address of your Pi, and click Connect
- Enter username and password to connect



Updated@2017-06-13:
VNC Server is now built-in to Raspberry Pi running RASPBIAN JESSIE WITH PIXEL. Please note that xrdp conflicts with the RealVNC server, so you shouldn’t install both at once.

This post show how to "Remote login Raspbian Jessie With Pixel using RealVNC Viewer from Windows".