2013年3月30日 星期六

Talking Inside/Outside Thermometer 溫度計拆解

Talking Inside/Outside Thermometer 溫度計拆解:

這個溫度計放在房間已有一段時間了,溫度計可以測量室外室內的溫度,讀數可選擇華氏或攝氏 (Fahrenheit / °F Celsius / °C ),最高和最低溫度,亦可以顯示時間和鬧鐘功能,還可以讀出當前溫度和時間 (英語),但是 LCD 顯示屏開始老化,顯示有點模糊,所以拆解看看內部結構,整機尺寸 123mm × 75mm × 30 / 15mm,計算機主 PCB 板(Main Control Board)尺寸 67mm × 58mm × 0.95mm

Talking Inside/Outside Thermometer 正面
Talking Inside/Outside Thermometer 背面
背面電池盒及支架
溫度 -58°F +158°F
溫度計內部
溫度計 PCB
溫度計 PCB 板及 LCD 顯示屏
內部溫度感測器
外部溫度感測器
Talking Inside/Outside Thermometer 溫度計規格
內部/外部溫度計兼鬧鐘
整點報時
清晰的真人語音
室內和室外的溫度
高低溫報警
記錄最高和最低溫度
簡單的時鐘,鬧鐘和貪睡
整點報時宣布當前的時間和溫度
大型清晰的液晶屏幕 43 × 36 毫米清除簡單的按鈕操作
2節AA電池(不包括)
參考售價:£17.35

20133 30 天氣報告
氣溫:19.4 @ 22:00
相對濕度:百分之 99%
天氣:雨

2013年3月29日 星期五

在 Windows XP Visual Studio 2010 安裝使用 FFmpeg 函數庫

Windows XP Visual Studio 2010 安裝使用 FFmpeg 函數庫:

由於 OpenCV 主要是針對圖像處理,在使用 WebCam 上的視頻編碼和解碼上有不足,特別在 M-JPEG Motion-JPEG)上,所以要試驗另外一個視頻庫 FFmpegFast Forward MPEG),FFmpeg 是一個基於 LGPL GPL 許可下免費軟件,FFmpeg 是完整及跨平台的錄製,轉換和串流音頻和視頻庫,主要用他來處理視頻內容,而且 M-JPEG over HTTP 是非常簡單實現,基本上祇要通知客戶端使用一個特殊的 mime-type 內容類型的 multipart/x-mixed-replace;boundary= informs,並發送一系列的分隔的 JPEG 文件,客戶端保持連接開啓,便可以不停地發送圖像。


FFmpeg 視頻庫組件: 
Libavcodec - 包含了所有 FFmpeg 的音頻/視頻編碼器和解碼器。 
Libav - 包含音頻/視頻容器格式的分路器和 muxers 的。 
Libavutil - 其中包含常見的不同部位的 ffmpeg 的例程。 
Libpostproc - 包含視頻後期處理例程。
Libswscale - 包含視頻圖像縮放程序。 
Libavfilter - 代替 vhook 它允許被修改或檢查視頻的解碼器和編碼器之間。 

FFmpeg 安裝:
1. 下載 OpenCV 2.4 檔案
http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.0/OpenCV-2.4.0.exe/download
2. 打開 C:\OpenCV2.4\opencv \CMakeLists.txt,加入 set(HAVE_FFMPEG 1)
3. C:\OpenCV2.4\opencv\3rdpaty\include\ffmpeg_\libavformat\avformat.h,加入 #define INT64_C
4. C:\OpenCV2.4\opencv\modules\highgui\src\cap_ffmpeg_impl.hpp,加入 #define snprintf _snprintf
5. 下載 FFmpeg 檔案,然後將 FFmpeg 檔案解壓放在 C:\FFMPEG
http://ffmpeg.zeranoe.com/builds/win32/dev/ffmpeg-20130329-git-551f683-win32-dev.7z


6. C/C++/C# 專案(Project)專案 → 屬性 → VC++目錄 → Include目錄(Additional Include Directories),加入C:\FFMPEG
專案 → 屬性→ VC++目錄 → Include目錄 → 編輯
7. C/C++/C# 專案(Project)專案→屬性→連結器→一般→其他程式庫目錄
Linker>General>Additional Library Dependencies),加入 C:\FFMPEG

連結器 → 輸入→ 其他相依性 → 編輯
8. C/C++/C# 專案(Project)專案→屬性→連結器→輸入→其他相依性
Linker>Input>Additional Dependencies),加入 avformat.lib, avscale.lib, avcore.lib

連結器 → 輸入→ 其他相依性 → 編輯
9. Visual Studio 2010 中建立 VC++ Win32 主控台應用程式,編寫 FFmpeg_webcam.cpp 程式。

FFmpeg_webcam.cpp 程式:
// opencv_webcam.cpp : 定義主控台應用程式的進入點。
//
#include "stdafx.h"
#include
#include
#include

int main()
{
    CvCapture *capture;
    IplImage *frame;

    capture=cvCreateCameraCapture(0);
    cvNamedWindow("Webcam",0);

    CvVideoWriter *writer;
    char AviFileName[]="Output.avi";
    int AviForamt = -1;
    int FPS = 25;
    CvSize AviSize = cvSize(640,480);
    int AviColor = 1;
    writer=cvCreateVideoWriter(AviFileName,AviForamt,FPS,AviSize,AviColor);

    int i=0;
    while(true)
    {
        frame = cvQueryFrame(capture);
        cvWriteFrame(writer,frame);

        cvShowImage("Webcam",frame);
        printf("%dn",i);

        if(cvWaitKey(20)>0)     break;
        i++;
    }

    cvReleaseCapture(&capture);
    cvReleaseVideoWriter(&writer);
    cvDestroyWindow("Webcam");
}

10. 執行程式顯示 Webcam 攝影圖像(Ctrl-F5
偵錯 啓動但不偵錯(Ctrl+F5
相關網址:
※ 在 Windows XP Visual Studio 2010 安裝 OpenCV 2.4
※ 在 Windows XP Visual Studio 2010 使用 OpenCV 2.4 第一個程式
※ 在 Windows XP Visual Studio 2010 使用 OpenCV 2.4 使用 WebCam
※ 在 Windows XP Visual Studio 2010 安裝使用 FFmpeg 函數庫
※ 在 Windows XP Visual Studio 2010 使用 OpenCV 2.4 使用 WebCam
※ 在 Windows XP Visual Studio 2010 使用 OpenCV 2.4 顯示 IPCam 串流視頻
※ 在 Windows XP Visual Studio 2010 使用 OpenCV 2.4 導入屬性工作表文件檔
※ 在 Windows XP Visual Studio 2010 使用 Windows From OpenCV 2.4 配置
※ 在 OpenCV 2.4 的 IplImage 資料結構
※ OpenCV 2.4 的坎尼圖像邊緣檢測(Canny Edge Detection) – Canny 函數
※ OpenCV 2.4 的霍夫直線偵測轉換 – HoughLines 函數
※ OpenCV 2.4 的霍夫直線偵測轉換 – HoughLinesP 函數
※ OpenCV 2.4 的人臉偵測(Face Detection)– cvHaarDetectObjects 函數
※ OpenCV 2.4 的物件偵測(Object Detection)– cvHoughCircles 函數
※ OpenCV 2.4 的物件追蹤(Object Tracking)– cvMoments 函數

參考網址: 
FFmpeg

2013329 天氣報告
氣溫:20.7 @ 23:00
相對濕度:百分之92%
天氣:微雨

2013年3月27日 星期三

在 Windows XP Visual Studio 2010 使用 OpenCV 2.4 使用 WebCam

Windows XP Visual Studio 2010 使用 OpenCV 2.4 使用 WebCam

筆者已購買了天敏(10Moons)暢快聊 S605 攝像頭(Webcam)作為智能小車之用,所以要試驗攝像頭(Webcam)是否可以篇程使用?如果攝像頭不可以篇程,那麼發展空間便有限了!

步驟 1 Visual Studio 2010 中建立 VC++ Win32 主控台應用程式
應用程式設定(名稱:opencv_webcam)→ 其它選項 → 空專案(勾選) → 完成
檔案 新增 專案 VC++ Win32 主控台應用程式 名稱 完成
歡迎使用 Win32應用程式精靈 完成
步驟 2點選 專案→屬性→VC++目錄 設定
Include目錄: 
C:\OpenCV2.4\opencv\build\include;
C:\OpenCV2.4\opencv\build\include\opencv;
專案 屬性
程式庫目錄: 
C:\OpenCV2.4\opencv\build\x86\vc10\lib;
程式庫目錄 編輯
步驟 3點選 專案→屬性→連結器→輸入 設定
其他相依性:
opencv_core240d.lib
opencv_calib3d240d.lib
opencv_contrib240d.lib
opencv_features2d240d.lib
opencv_highgui240d.lib
opencv_imgproc240d.lib
連結器 輸入→ 其他相依性 編輯
步驟 4編寫 VC++ 程式(opencv_webcam.cpp
編寫 opencv_webcam.cpp程式
Opencv_webcam.cpp 程式:
// opencv_webcam.cpp : 定義主控台應用程式的進入點。
//
#include "stdafx.h"
#include

int _tmain(int argc, _TCHAR* argv[])
{
    int c;
    // allocate memory for an image
    IplImage *img;
    // capture from video device #1
    CvCapture* capture = cvCaptureFromCAM(1);
    // create a window to display the images
    cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE);
    // position the window
    cvMoveWindow("mainWin", 5, 5);
    while(1)
    {
        // retrieve the captured frame
        img=cvQueryFrame(capture);

        // show the image in the window
        cvShowImage("mainWin", img );

        // wait 10 ms for a key to be pressed
        c=cvWaitKey(10);
        // escape key terminates program
        if(c == 27)
        break;
    }

 return 0;
}

步驟 5連接天敏(10Moons)暢快聊 S605 攝像頭(Webcam)在電腦的 USB上。
連接 Webcam在電腦的 USB插座
步驟 6:設置在 Debug 模式,啓動但不偵錯(Ctrl+F5
偵錯 啓動但不偵錯(Ctrl+F5
步驟 7程式執行並顯示 Webcam 攝影圖像
成功顯示動態圖像!