标题:
QT网络视频监控系统代码
[打印本页]
作者:
chn756464426
时间:
2019-4-11 14:45
标题:
QT网络视频监控系统代码
可以实现在web上查看摄像头采集的图像
0.png
(11.69 KB, 下载次数: 13)
下载附件
2019-4-11 17:09 上传
单片机源程序如下:
#include<stdio.h>
#include"srv.h"
#include"cam.h"
#include"web.h"
pthread_mutex_t cam_mutex;
pthread_mutex_t sync_mutex;
pthread_t cam_tid;
pthread_t web_tid;
int sync_flag = 2;
int main(int argc,char *argv[])
{
int ret;
pthread_mutex_init(&cam_mutex,NULL);
pthread_mutex_init(&sync_mutex,NULL);
#if 1
ret = pthread_create(&cam_tid,NULL,thread_cam,NULL);
if(ret)
{
errno = ret;
perror("create camera thread ");
exit(EXIT_FAILURE);
}else
printf("create camera thread success\n");
ret = pthread_detach(cam_tid);
if(ret)
{
errno = ret;
perror("detach camera thread ");
exit(EXIT_FAILURE);
}else
printf("detach camera thread success\n");
#endif
#if 0
ret = pthread_create(&zgb_tid,NULL,thread_zgb,NULL);
if(ret)
{
errno = ret;
perror("create zigbee thread ");
exit(EXIT_FAILURE);
}else
printf("create zigbee thread success\n");
ret = pthread_detach(zgb_tid);
if(ret)
{
errno = ret;
perror("detach zigbee thread\n");
exit(EXIT_FAILURE);
}else
printf("detach zigbee thread success\n");
#endif
#if 0
while(1)
{
pthread_mutex_lock(&sync_mutex);
if(0 == sync_flag)
{
pthread_mutex_unlock(&sync_mutex);
pthread_mutex_destroy(&sync_mutex);
break;
}else{
pthread_mutex_unlock(&sync_mutex);
sleep(1);
}
}
#endif
#if 1
ret = pthread_create(&web_tid,NULL,thread_web,NULL);
if(ret)
{
errno = ret;
perror("create web server thread\n");
exit(EXIT_FAILURE);
}else
printf("create web server thread success\n");
ret = pthread_detach(web_tid);
if(ret)
{
errno = ret;
perror("detach web server thread\n");
exit(EXIT_FAILURE);
}else
printf("detach web server thread success\n");
#endif
int listenfd = init_socket(8880,argv[1]);
while(1)
{
int connectfd = accept(listenfd,NULL,NULL);
printf("%d\n",connectfd);
if(-1 == connectfd)
{
perror("accept ");
exit(EXIT_FAILURE);
}
pthread_t srv_tid;
ret = pthread_create(&srv_tid,NULL,thread_srv,&connectfd);
if(ret)
{
errno = ret;
perror("create server thread\n");
exit(EXIT_FAILURE);
}else
printf("create server thread success\n");
ret = pthread_detach(srv_tid);
if(ret)
{
errno = ret;
perror("detach server thread\n");
exit(EXIT_FAILURE);
}else
printf("detach server thread success\n");
}
pthread_mutex_destroy(&cam_mutex);
sercache_destroy(jpegn) ;
sercache_destroy(head);
return 0;
}
复制代码
所有资料51hei提供下载:
video monitor.7z
(373.5 KB, 下载次数: 33)
2019-4-11 17:10 上传
点击文件名下载附件
下载积分: 黑币 -5
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1