找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2523|回复: 0
打印 上一主题 下一主题
收起左侧

QT网络视频监控系统代码

[复制链接]
跳转到指定楼层
楼主
可以实现在web上查看摄像头采集的图像


单片机源程序如下:
  1. #include<stdio.h>

  2. #include"srv.h"
  3. #include"cam.h"
  4. #include"web.h"

  5. pthread_mutex_t cam_mutex;
  6. pthread_mutex_t sync_mutex;

  7. pthread_t cam_tid;
  8. pthread_t web_tid;

  9. int sync_flag = 2;

  10. int main(int argc,char *argv[])
  11. {
  12.         int ret;

  13.         pthread_mutex_init(&cam_mutex,NULL);
  14.         pthread_mutex_init(&sync_mutex,NULL);

  15. #if 1
  16.         ret = pthread_create(&cam_tid,NULL,thread_cam,NULL);
  17.         if(ret)
  18.         {
  19.                 errno = ret;
  20.                 perror("create camera thread ");
  21.                 exit(EXIT_FAILURE);
  22.         }else
  23.                 printf("create camera thread success\n");

  24.         ret = pthread_detach(cam_tid);
  25.         if(ret)
  26.         {
  27.                 errno = ret;
  28.                 perror("detach camera thread ");
  29.                 exit(EXIT_FAILURE);
  30.         }else
  31.                 printf("detach camera thread success\n");
  32. #endif

  33. #if 0
  34.         ret = pthread_create(&zgb_tid,NULL,thread_zgb,NULL);
  35.         if(ret)
  36.         {
  37.                 errno = ret;
  38.                 perror("create zigbee thread ");
  39.                 exit(EXIT_FAILURE);
  40.         }else
  41.                 printf("create zigbee thread success\n");
  42.         ret = pthread_detach(zgb_tid);
  43.         if(ret)
  44.         {
  45.                 errno = ret;
  46.                 perror("detach zigbee thread\n");
  47.                 exit(EXIT_FAILURE);
  48.         }else
  49.                 printf("detach zigbee thread success\n");
  50. #endif

  51. #if 0

  52.         while(1)
  53.         {
  54.                 pthread_mutex_lock(&sync_mutex);
  55.                 if(0 == sync_flag)
  56.                 {
  57.                         pthread_mutex_unlock(&sync_mutex);
  58.                         pthread_mutex_destroy(&sync_mutex);
  59.                         break;
  60.                 }else{
  61.                         pthread_mutex_unlock(&sync_mutex);
  62.                         sleep(1);
  63.                 }
  64.         }
  65. #endif
  66. #if 1
  67.         ret = pthread_create(&web_tid,NULL,thread_web,NULL);
  68.         if(ret)
  69.         {
  70.                 errno = ret;
  71.                 perror("create web server thread\n");
  72.                 exit(EXIT_FAILURE);
  73.         }else
  74.                 printf("create web server thread success\n");

  75.         ret = pthread_detach(web_tid);
  76.         if(ret)
  77.         {
  78.                 errno = ret;
  79.                 perror("detach web server thread\n");
  80.                 exit(EXIT_FAILURE);
  81.         }else
  82.                 printf("detach web server thread success\n");

  83. #endif

  84.         int listenfd = init_socket(8880,argv[1]);

  85.         while(1)
  86.         {
  87.                 int connectfd = accept(listenfd,NULL,NULL);
  88.                 printf("%d\n",connectfd);
  89.                 if(-1 == connectfd)
  90.                 {
  91.                         perror("accept ");
  92.                         exit(EXIT_FAILURE);
  93.                 }

  94.                 pthread_t srv_tid;
  95.                 ret = pthread_create(&srv_tid,NULL,thread_srv,&connectfd);
  96.                 if(ret)
  97.                 {
  98.                         errno = ret;
  99.                         perror("create server thread\n");
  100.                         exit(EXIT_FAILURE);
  101.                 }else
  102.                         printf("create server thread success\n");

  103.                 ret = pthread_detach(srv_tid);
  104.                 if(ret)
  105.                 {
  106.                         errno = ret;
  107.                         perror("detach server thread\n");
  108.                         exit(EXIT_FAILURE);
  109.                 }else
  110.                         printf("detach server thread success\n");
  111.         }
  112.         
  113.         pthread_mutex_destroy(&cam_mutex);
  114.         sercache_destroy(jpegn)        ;
  115.         sercache_destroy(head);

  116.         return 0;
  117. }

复制代码

所有资料51hei提供下载:
video monitor.7z (373.5 KB, 下载次数: 33)


评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏2 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表