欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 2743|回復: 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 單片機教程網

快速回復 返回頂部 返回列表