資源簡介
linux下實現的攝像頭實時視頻數據傳輸demo,可根據自己的需求更改,可用cmake編譯(需完整安裝opencv),也可用g++編譯(需部分編譯pence庫-lopencv_core -lopencv_video -lopencv_highgui -lopencv_imgproc):服務端 g++ simple_server_main.cpp ServerSocket.cpp Socket.cpp -o server -I . -I/usr/local/include -L/usr/local/lib -lopencv_core -lopencv_video -lopencv_highgui -lopencv_imgproc 客戶端: g++ simple_client_main.cpp ClientSocket.cpp Socket.cpp -o client -I ~/work/experiment/c++/socket/socket-opencv/src -I/usr/local/include -L/usr/local/lib -lopencv_core -lopencv_video -lopencv_highgui -lopencv_imgproc 也可用你自己的IDE編譯
代碼片段和文件信息
//?Implementation?of?the?ClientSocket?class
#include?“ClientSocket.h“
#include?“SocketException.h“
ClientSocket::ClientSocket?(?std::string?host?int?port?)
{
??if?(?!?Socket::create()?)
????{
??????throw?SocketException?(?“Could?not?create?client?socket.“?);
????}
??if?(?!?Socket::connect?(?host?port?)?)
????{
??????throw?SocketException?(?“Could?not?bind?to?port.“?);
????}
}
const?ClientSocket&?ClientSocket::operator?<(?const?std::string&?s?)?const
{
??if?(?!?Socket::send?(?s?)?)
????{
??????throw?SocketException?(?“Could?not?write?to?socket.“?);
????}
??return?*this;
}
const?ClientSocket&?ClientSocket::operator?<(?const?cv::Mat&?mat?)?const
{
????if?(?!?Socket::send?(?mat?)?)
????????{
????????????throw?SocketException?(?“Could?not?write?to?socket.“?);
????????}
????return?*this;
}
const?ClientSocket&?ClientSocket::operator?>>?(?std::string&?s?)?const
{
??if?(?!?Socket::recv?(?s?)?)
????{
??????throw?SocketException?(?“Could?not?read?from?socket.“?);
????}
??return?*this;
}
const?ClientSocket&?ClientSocket::operator?>>?(?cv::Mat&?mat?)?const
{
????if?(?!?Socket::recv?(?mat?)?)
????????{
????????????throw?SocketException?(?“Could?not?read?from?socket.“?);
????????}
????return?*this;
}
- 上一篇:基于MFC的圖像處理
- 下一篇:寫入磁盤小工具(將bin寫入到img磁盤)
評論
共有 條評論