2016年10月27日 星期四

[創業] Kano + Snap Circuits

有這樣想法的人真多, 內容為王還是硬體為王?

https://hackaday.io/project/12316-raspberry-pi-3-desktop-a-7-yr-old-can-build-use/log/40562-request-for-project-ideas-for-raspberry-pi-3-desktop-a-7-yr-old-can-build-use

[RPi] picamera + OpenCV

之前試 picamera 不知道怎麼接到 OpenCV, 剛剛看了這篇, 學習了

不廢話直接看兩支程式吧 (imutils_camera.py)
#!/usr/bin/python

from imutils.video import VideoStream
import imutils
import time
import cv2 

vs = VideoStream(usePiCamera=1).start()
time.sleep(1)
width  = int(640)
height = int(480)

while True:
    start = time.time()

    # picamera videostream read
    frame = vs.read()
    frame = imutils.resize(frame, width=width)
    cv2.imshow("preview", frame)

    end = time.time()
    seconds = end - start
    print "time : {0} sec".format(round(seconds, 3)) 
    fps  = 1 / seconds;
    print "fps : {0}".format(round(fps, 3));

    if cv2.waitKey(1) & 0xFF == ord("q"):
        break

cv2.destroyAllWindows()
使用前要先 sudo pip install imutils


另外是使用 V4L2, 程式碼(v4l2_camera.py)
#!/usr/bin/python

import cv2 
import time

cap = cv2.VideoCapture(0)
cap.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH,  640)
cap.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT, 480)

while True:
    start = time.time()

    # v4l2 read
    ret, frame = cap.read()
    cv2.imshow("preview", frame)

    end = time.time()
    seconds = end - start
    print "time : {0} sec".format(round(seconds, 3)) 
    fps  = 1 / seconds;
    print "fps : {0}".format(round(fps, 3));

    if cv2.waitKey(1) & 0xFF == ord("q"):
        break

cap.release()
cv2.destroyAllWindows()
使用前要先 sudo modprobe bcm2835-v4l2

這樣寫看起來是使用 picamera 反而比較慢, 如果用原型的話就可以看出還是 V4L2 比較慢
import picamera
from picamera.array import PiRGBArray
import time
import cv2 

time.sleep(1)
resolution = (640, 480)

with picamera.PiCamera() as camera:
    camera.resolution = resolution
    rawCapture = PiRGBArray(camera, size=resolution)
    stream = camera.capture_continuous(rawCapture, format="bgr", use_video_port=True)
        
    for f in stream:
        start = time.time()

        frame = f.array
        rawCapture.truncate(0)
        cv2.imshow("preview", frame)

        end = time.time()
        seconds = end - start
        print "time : {0} sec".format(round(seconds, 3)) 
        fps  = 1 / seconds;
        print "fps : {0}".format(round(fps, 3));

        if cv2.waitKey(1) & 0xFF == ord("q"):
            break


2016年10月23日 星期日

[Git] 寫個好的README

一直都沒有認真寫 README, 沒有說明很糟糕

可以參考 Raspberry Pi 的 Raw, 從這篇看起吧

https://raw.githubusercontent.com/raspberrypi/documentation/master/README.md

2016年10月10日 星期一

[Wordpress] 解決無法直接安裝/更新plugin問題(Connection Information)


使用 wordpress 要安裝 plugin 常常會出現這個畫面, 只好手動安裝或是更新, 頗為麻煩

只要將 wordpress 的使用者和群組改為 www-data 就搞定了... 不過不知道會不會有安全上的問題阿?
sudo chown -R www-data:www-data wordpress

2016年10月9日 星期日

[RPi] 從OpenMAX到MMAL

Raspberry Pi 的 GPU(VideoCore)使用的範例不多, 但非常強大

可以參考這兩篇做入門, 要搭配 firmware/documentation/ilcomponents 一起使用
1. Raspberry Pi: VideoCore #1
2. Raspberry Pi: VideoCore #2, MMAL


2016年10月7日 星期五

[IoT] Pulse Sensor

購買頁面:[產品] 脈搏感測器模組(Pulse Sensor)

1. Pulse Sensor 環境設定:
arduino 1.5.8 + github

2. Pulse Sensor 修改(Arduino)
1.) static boolean serialVisual = true; // Set to 'false' by Default. Re-set to 'true' to see Arduino Serial Monitor ASCII Visual Pulse
2). delay(2000); // take a break

3. Arduino 藍牙設定, 需配合 pulse sensor 將 BT 的 UART 改為 115200

設定程式碼
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
 
void setup()
{
  pinMode(9, OUTPUT);
  digitalWrite(9, HIGH);
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
 
  Serial.println("Ready!");
  // for HC-05 use 38400 when poerwing with KEY/STATE set to HIGH on power on
  mySerial.begin(9600);
}
 
void loop() // run over and over
{
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}

2016年9月25日 星期日

[作業系統] 用十分鐘 向jserv學習作業系統設計

金門大學陳鍾誠老師將 jserv 的程式碼解釋的非常清楚, 看來要找個時間開始動手實做了

用十分鐘 向jserv學習作業系統設計