资源简介
程序中一个是server端,一个是client端,使用了socket和opencv,server端截屏发送给client端,client端显示,就好像远程桌面一样。
代码片段和文件信息
// Win32Project1.cpp : 定义控制台应用程序的入口点。
//
#include “stdafx.h“
#include
#include
#include
#include
#pragma comment(lib “ws2_32.lib“)
#pragma comment(lib “opencv_core247d.lib“)
#pragma comment(lib “opencv_highgui247d.lib“)
#pragma comment(lib “opencv_imgproc247d.lib“)
typedef struct MyStruct
{
int i_width;
int i_height;
int i_depth;
int i_nchannels;
LONG64 i_dlength;
}* MYSTRUCT;
IplImage* screemImage;
int flag = 0;
void main()
{
WSADATA wsaData;
if (0 != WSAStartup(MAKEWORD(22) &wsaData))
{
MessageBox(NULL “WSAStartup error\n“ “error“ MB_OK);
return;
}
SOCKET clientSocket = socket(AF_INET SOCK_STREAM 0);
SOCKADDR_IN clientsock_in;
clientsock_in.sin_addr.S_un.S_addr = inet_addr(“192.168.168.47“);
clientsock_in.sin_family = AF_INET;
clientsock_in.sin_port = htons(6000);
connect(clientSocket (SOCKADDR*)&clientsock_in sizeof(SOCKADDR));
//int iii = 0;
while(1)
{
/*if (iii == 0)
{
char ss[1] = {0};
recv(clientSocket ss 1 0);
if (ss[0] != ‘*‘)
{
continue;
}
iii++;
}*/
int len = sizeof(MyStruct);
char *receiveBuf = new char[len];
memset(receiveBuf 0 len);
if(recv(clientSocket receiveBuf len 0) < 0)
{
MessageBox(NULL “recv“ “error“ MB_OK);
delete []receiveBuf;
break;
}
MYSTRUCT sData = MYSTRUCT(receiveBuf);
LONG64 tl = sData->i_dlength;
BYTE *imgedata = new BYTE[tl];
memset(imgedata 0 tl);
int al = 0;
while(al < tl)
{
int el = 800;
if (tl - al < 800)
{
el = tl - al;
}
int rl = recv(clientSocket (char*)(imgedata + al) el 0);
if(0 == rl)
{
MessageBox(NULL “recv“ “error“ MB_OK);
break;
}
al += rl;
}
if(flag == 0)
{
screemImage = cvCreateImage(cvSize(sData->i_width sData->i_height) sData->i_depth sData->i_nchannels);
flag = 1;
}
LONG64 ttl = (sData->i_height)*(sData->i_width)*(sData->i_nchannels);
if (ttl != tl)
{
MessageBox(NULL “ttl != tl“ “error“ MB_OK);
delete []receiveBuf;
delete []imgedata;
break;
}
memcpy(screemImage->imageData imgedata (sData->i_height)*(sData->i_width)*(sData->i_nchannels));
IplImage* screenRGB = 0;
IplImage* screen_resize = 0;
if(!screen_resize)
screen_resize = cvCreateImage(cvSize(1536 900) sData->i_depth sData->i_nchannels);
cvResize(screemImage screen_resize CV_INTER_LINEAR);
if(!screenRGB)
screenRGB = cvCreateImage(cvSize(1536 900) IPL_DEPTH_8U 3);
cvCvtColor(screen_resize screenRGB CV_RGBA2RGB);
cvShowImage(“desktop“ screenRGB);
cvReleaseImage(&screen_resize);
cvReleaseImage(&screenRGB);
char c = cvWaitKey(33);
if (c == 27)
{
delete []receiveBuf;
delete []imgedata;
break;
}
delete []receiveBuf;
delete []imgedata;
}
cvDestroyAllWindows();
closesocket(client
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-01-07 14:17 Win32Project2\
目录 0 2014-01-07 14:17 Win32Project2\client\
文件 4650 2013-12-09 15:55 Win32Project2\client\client.vcxproj
文件 1320 2013-12-09 13:34 Win32Project2\client\client.vcxproj.filters
文件 3045 2014-01-07 14:12 Win32Project2\client\clientScreenshot.cpp
文件 1503 2013-12-09 13:33 Win32Project2\client\ReadMe.txt
文件 211 2013-12-09 13:33 Win32Project2\client\stdafx.cpp
文件 233 2013-12-09 13:33 Win32Project2\client\stdafx.h
文件 236 2013-12-09 13:33 Win32Project2\client\targetver.h
目录 0 2014-01-07 14:17 Win32Project2\Debug\
文件 501248 2014-01-07 14:12 Win32Project2\Debug\client.exe
文件 3671552 2013-11-07 11:05 Win32Project2\Debug\opencv_core247d.dll
文件 3825152 2013-11-07 11:06 Win32Project2\Debug\opencv_highgui247d.dll
文件 3399168 2013-11-07 11:05 Win32Project2\Debug\opencv_imgproc247d.dll
文件 501248 2014-01-06 14:37 Win32Project2\Debug\server.exe
目录 0 2014-01-07 14:17 Win32Project2\server\
文件 1503 2013-12-09 13:33 Win32Project2\server\ReadMe.txt
文件 4591 2013-12-09 13:48 Win32Project2\server\server.vcxproj
文件 1320 2013-12-09 13:34 Win32Project2\server\server.vcxproj.filters
文件 164 2013-12-09 13:35 Win32Project2\server\server.vcxproj.user
文件 3379 2013-12-09 17:37 Win32Project2\server\serverScreenshot.cpp
文件 211 2013-12-09 13:33 Win32Project2\server\stdafx.cpp
文件 233 2013-12-09 13:33 Win32Project2\server\stdafx.h
文件 236 2013-12-09 13:33 Win32Project2\server\targetver.h
文件 1342 2013-12-09 13:34 Win32Project2\Win32Project2.sln
相关资源
- STM32F107的socket
- Keras图像深度学习实战原版
- 训练得到的900维 HOG特征-检测算子进行
- msvcp120d .dll、msvcr120d.dll包括32位和64位
- 基于VS2010的CSocket网络文件传输
- qt+opencv的视频采集 与保存
- WebEx Recording Editor 2014最新版
- opencv做的姿态检测项目
- opencv运动目标检测帧差法
- libwebsockets-master.rar
- 基于opencv的双目摄像头图像获取
- opencv vlc 访问海康网络摄像头
- 快速小波变换 基于opencv带注释
- opencvman_old.pdf
- led屏发布系统 通信加密解密 socket通
- 基于socket的即时通信
- 车牌识别系统vc源码基于opencv
- 基于opencv的双摄像头读取程序含Dire
- 序列图像16位转8位OpenCV
- Opencv图像Mat写入中文汉字
- opencv学习,道路检测
- 基于OpenCV的二维码检测识别基础demo
- Wallis滤波
- Opencv 人脸图像素描化
- Linux 环境下,利用 Socket 通信实现网络
- 基于OpenCV读取摄像头的人脸检测和识
- 基于OpenCv的旋转匹配
- opencv果实分割与识别
- Qt实现Socket断线重连机制
- qt环境下使用opencv打开双摄像头并保存
评论
共有 条评论