Android與Arduino之間使用bluetooth溝通
2011年6月7日 星期二
2011年5月14日 星期六
open cv的使用
1. 下載OpenCV
http://sourceforge.net/projects/opencvlibrary/
2. 安裝OpenCV
3. Add OpenCV to the system PATH for all users
3A.將 c:\openCV2.2\bin 的 opencv_core220d.dll、opencv_highgui220d.dll、
opencv_objdetect220d.dll、opencv_imgproc220d.dll拷貝到 c:windows\system32
4. 安裝Microsoft Visual Studio 2010
5. 在 VS.NET 2010下新增一個 Win32 Console Application
6. 將opencv_highgui220d.lib;opencv_core220d.lib;opencv_imgproc220d.lib;
加入 OpenCV程式庫( libraries )
在VS.NET 2010的 Project->Property->Linker->Input->AdditionalDependencies:下
加入opencv_highgui220d.lib;opencv_core220d.lib;opencv_imgproc220d.lib;
7. 將C:\OpenCV2.2\include\opencv;C:\OpenCV2.2\include加入OpenCV Include Directory
在VS.NET 2010主功能表的 Configuration Property->VC++ Directories->Include Directories
加入 C:\OpenCV2.2\include\opencv;C:\OpenCV2.2\include;
8. Add OpenCV Directory"C:\OpenCV2.2\lib;"to VC++ Directories->Library Directories
9. 使用 範例 1 顯示圖片
#include "stdafx.h"
#include
#include
using namespace cv;
int main(int argc, char** argv)
{
Mat imgSrc;
imgSrc = imread("lena.jpg") ;
namedWindow("Src") ;
imshow("Src",imgSrc) ;
waitKey(0);
destroyWindow("Src")
return 0;
}
10. 範例2 彩色轉黑白
#include "stdafx.h"
#include
#include
using namespace cv;
int main(int argc, char** argv){
Mat imgSrc; Mat imgDst;
imgSrc = imread("lena.jpg") ;
cvtColor(imgSrc, imgDst, CV_RGB2GRAY);
namedWindow("Src") ;
namedWindow("Dst");
imshow("Src",imgSrc) ;
imshow("Dst",imgDst) ;
waitKey(0);
destroyWindow("Src") ;
destroyWindow("Dst") ;
return 0;
}
11.範例 3 使用攝影機
#include "stdafx.h"
#include
#include
using namespace cv;
int main(int, char**){
VideoCapture cap(0);
if(!cap.isOpened()) return -1;
Mat edges; namedWindow("edges",1);
for(;;) {
Mat frame;
cap >> frame;
cvtColor(frame, edges, CV_BGR2GRAY);
GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
Canny(edges, edges, 0, 30, 3);
imshow("edges", edges);
if(waitKey(30) >= 0) break;
}
// the camera will be deinitialized automatically in VideoCapture destructor
return 0;
}
http://sourceforge.net/projects/opencvlibrary/
2. 安裝OpenCV
3. Add OpenCV to the system PATH for all users
3A.將 c:\openCV2.2\bin 的 opencv_core220d.dll、opencv_highgui220d.dll、
opencv_objdetect220d.dll、opencv_imgproc220d.dll拷貝到 c:windows\system32
4. 安裝Microsoft Visual Studio 2010
5. 在 VS.NET 2010下新增一個 Win32 Console Application
6. 將opencv_highgui220d.lib;opencv_core220d.lib;opencv_imgproc220d.lib;
加入 OpenCV程式庫( libraries )
在VS.NET 2010的 Project->Property->Linker->Input->AdditionalDependencies:下
加入opencv_highgui220d.lib;opencv_core220d.lib;opencv_imgproc220d.lib;
7. 將C:\OpenCV2.2\include\opencv;C:\OpenCV2.2\include加入OpenCV Include Directory
在VS.NET 2010主功能表的 Configuration Property->VC++ Directories->Include Directories
加入 C:\OpenCV2.2\include\opencv;C:\OpenCV2.2\include;
8. Add OpenCV Directory"C:\OpenCV2.2\lib;"to VC++ Directories->Library Directories
9. 使用 範例 1 顯示圖片
#include "stdafx.h"
#include
#include
using namespace cv;
int main(int argc, char** argv)
{
Mat imgSrc;
imgSrc = imread("lena.jpg") ;
namedWindow("Src") ;
imshow("Src",imgSrc) ;
waitKey(0);
destroyWindow("Src")
return 0;
}
10. 範例2 彩色轉黑白
#include "stdafx.h"
#include
#include
using namespace cv;
int main(int argc, char** argv){
Mat imgSrc; Mat imgDst;
imgSrc = imread("lena.jpg") ;
cvtColor(imgSrc, imgDst, CV_RGB2GRAY);
namedWindow("Src") ;
namedWindow("Dst");
imshow("Src",imgSrc) ;
imshow("Dst",imgDst) ;
waitKey(0);
destroyWindow("Src") ;
destroyWindow("Dst") ;
return 0;
}
11.範例 3 使用攝影機
#include "stdafx.h"
#include
#include
using namespace cv;
int main(int, char**){
VideoCapture cap(0);
if(!cap.isOpened()) return -1;
Mat edges; namedWindow("edges",1);
for(;;) {
Mat frame;
cap >> frame;
cvtColor(frame, edges, CV_BGR2GRAY);
GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
Canny(edges, edges, 0, 30, 3);
imshow("edges", edges);
if(waitKey(30) >= 0) break;
}
// the camera will be deinitialized automatically in VideoCapture destructor
return 0;
}
2011年5月12日 星期四
讓xampp在windows環境下以gmail的smtp發信設定
讓xampp在windows環境下以gmail的smtp發信設定
因為需要測試php的mail函式,在windows下的sendmail並沒辦法使用。
而xampp的MercuryMail設定,若僅是測試又嫌麻煩,於是爬了文並實際使用,經過測試可行了,紀錄如下:
照例關鍵字:xampp、php、mail()、gmail、smtp、stunnel、windows環境
xampp不贅述了,看倌請自行下載。
首先先下載 stunnel,此篇運行時版本為4.27,點此下載。
運作原理
xampp在windows下apache並不能直接使用mail()函式,必須藉由xampp內帶的sendmail.exe模擬sendmail函式。
當設定好sendmail的相關設置後,一般就可以透過本身ISP業者提供的smtp進行郵件發送。
但gmail必須使用SSL安全連線方式登入後才可連入smtp寄送,於是使用stunnel,讓它來代理SSL連線。
而設置好後,xampp的sendmail.exe透過stunnel以SSL模式連入gmail的smtp伺服器,sendmail就能夠使用gmail的smtp進行郵件的發送了。
而xampp的apche就能夠透過sendmail.exe來運行php的mail()函式,而不用在架設郵件伺服器。
相關設定
apache
php.ini 檔,位置在 \xampp\apache\bin\php.ini
約700多行
SMTP = localhost
smtp_port = 25
sendmail_from = sample@gamil.com ← 改為寄信者的郵件
sendmail_path = "D:\xampp\sendmail\sendmail.exe -t" ← 路徑必須設定對
另外約在636行
extension=php_openssl.dll ← 將openssl啟動
/*---------------------------------------*/
sendmail
sendmail.ini 檔,位置在D:\xampp\sendmail\sendmail
若原本是註解(前面有分號;),就把前面的;拿掉,讓其執行。
smtp_server=localhost
smtp_port=25
default_domain=gmail.com
error_logfile=error.log
約在27行
auth_username=sample@gmail.com ← gmail信箱
auth_password=password ← 輸入你的gmail密碼
約41行
force_sender=sample@gmail.com ← gmail信箱
/*---------------------------------------*/
stunnel
stunnel.conf 檔,位置在 C:\Program Files\stunnel\stunnel.conf
原本是註解的就拿掉分號,取消註解。
cert = stunnel.pem
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
debug = 7
output = stunnel.log
client = yes
[ssmtp]
accept = 127.0.0.1:25
connect = smtp.gmail.com:465
上面都設定好了以後,記得gmail必須打開POP功能
開啟方式為:進入gmail,右上角設定 → 轉寄和POP/IMAP → POP下載 啟用POP功能 即可。
而apache重新啟動以後,就可以透過php的mail()函式進行郵件發送囉。
以上
心得紀錄
參考文件:http://www.projectpier.org/node/817、http://zcdxzsz.javaeye.com/blog/254098
因為需要測試php的mail函式,在windows下的sendmail並沒辦法使用。
而xampp的MercuryMail設定,若僅是測試又嫌麻煩,於是爬了文並實際使用,經過測試可行了,紀錄如下:
照例關鍵字:xampp、php、mail()、gmail、smtp、stunnel、windows環境
xampp不贅述了,看倌請自行下載。
首先先下載 stunnel,此篇運行時版本為4.27,點此下載。
運作原理
xampp在windows下apache並不能直接使用mail()函式,必須藉由xampp內帶的sendmail.exe模擬sendmail函式。
當設定好sendmail的相關設置後,一般就可以透過本身ISP業者提供的smtp進行郵件發送。
但gmail必須使用SSL安全連線方式登入後才可連入smtp寄送,於是使用stunnel,讓它來代理SSL連線。
而設置好後,xampp的sendmail.exe透過stunnel以SSL模式連入gmail的smtp伺服器,sendmail就能夠使用gmail的smtp進行郵件的發送了。
而xampp的apche就能夠透過sendmail.exe來運行php的mail()函式,而不用在架設郵件伺服器。
相關設定
apache
php.ini 檔,位置在 \xampp\apache\bin\php.ini
約700多行
SMTP = localhost
smtp_port = 25
sendmail_from = sample@gamil.com ← 改為寄信者的郵件
sendmail_path = "D:\xampp\sendmail\sendmail.exe -t" ← 路徑必須設定對
另外約在636行
extension=php_openssl.dll ← 將openssl啟動
/*---------------------------------------*/
sendmail
sendmail.ini 檔,位置在D:\xampp\sendmail\sendmail
若原本是註解(前面有分號;),就把前面的;拿掉,讓其執行。
smtp_server=localhost
smtp_port=25
default_domain=gmail.com
error_logfile=error.log
約在27行
auth_username=sample@gmail.com ← gmail信箱
auth_password=password ← 輸入你的gmail密碼
約41行
force_sender=sample@gmail.com ← gmail信箱
/*---------------------------------------*/
stunnel
stunnel.conf 檔,位置在 C:\Program Files\stunnel\stunnel.conf
原本是註解的就拿掉分號,取消註解。
cert = stunnel.pem
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
debug = 7
output = stunnel.log
client = yes
[ssmtp]
accept = 127.0.0.1:25
connect = smtp.gmail.com:465
上面都設定好了以後,記得gmail必須打開POP功能
開啟方式為:進入gmail,右上角設定 → 轉寄和POP/IMAP → POP下載 啟用POP功能 即可。
而apache重新啟動以後,就可以透過php的mail()函式進行郵件發送囉。
以上
心得紀錄
參考文件:http://www.projectpier.org/node/817、http://zcdxzsz.javaeye.com/blog/254098
2011年4月8日 星期五
drupal 安裝
1. 下載drupal 7.0版
2. 解壓縮後放到 /var/www 目錄下
3. enable php extension .gd,請輸入已下指令
apt-get install php5-gd
invoke -rc.d apache2 restart
4. 新增目錄 /var/www/drupal/sites/default/files
5. 拷貝檔案
cp /var/www/drupal/sites/default/default.settings.php /var/www/drupal/sites/default/settings.php
6.
2. 解壓縮後放到 /var/www 目錄下
3. enable php extension .gd,請輸入已下指令
apt-get install php5-gd
invoke -rc.d apache2 restart
4. 新增目錄 /var/www/drupal/sites/default/files
5. 拷貝檔案
cp /var/www/drupal/sites/default/default.settings.php /var/www/drupal/sites/default/settings.php
6.
訂閱:
文章 (Atom)