Coder Social home page Coder Social logo

algserver's Introduction

人脸识别算法服务器

使用C++、opencv、Qt4.8.6编写的人脸识别算法服务器

2016.07.22

这几天整理程序时,把几个源代码集中上传到github上
这个程序算是之前项目的一个实验程序,一些具体细节还没开发、调试完,先上传上来。

主要功能

算法开发中遇到这样的问题:人脸检测这样实时性要求高的算法可以直接在前端跑,而人脸识别这样的算法有时对平台依赖性强,有的还有加密的需求,且算法开销大,无法跟上人脸检测的速度。
后来看到Face++提供算法的模式:人脸检测部分使用离线SDK打包给用户,人脸识别部分采取http协议远程调用的方式提供服务
这里想模仿这种模式,把检测算法做成工具类,把识别算法做成请求/响应的模式。

使用

开发时用的环境为VS2010、opencv2.4.6、Qt4.8.6。 上传前试了一下,程序框架写好了,没有完全调试好。
程序包括一个服务端和一个客户端。服务端即solution try_tcpservser中的try_tcpservser工程,客户端即test_socket中的TestTCPClient工程。 先运行服务端程序,会出现下面这个简单的窗口:
server
连接和日志信息都打印在窗口上。
再运行客户端,连接上之后就是采集摄像头图像进行人脸检测,然后和服务端通信进行人脸识别,接收识别结果(这里只是一个测试用的控制台程序)。

程序结构

这是程序的框图:
algServer

  • 左边是服务端,TCPServer监听端口,每路连接请求创建一个clientsocket对象。
    clientsocket对象可能收到两种包:人脸数据包和心跳包。人脸数据包中包含待识别的人脸对,每张人脸由GUID和图片数据组成。心跳包则为了维持连接而发送。
    使用CFace提供的静态方法可以将数据包转换成对象,使用CIFaceRecog类做人脸识别。CIFaceRecog类,是抽象类,继承了CIRunnable接口;CFaceRecogSURF是它的一个实现类,使用SURF算法进行人脸识别,实际使用中可提供其它人脸识别类。
    人脸识别的请求用CFaceRecog接口包装送入线程池中。线程池使用pthread库实现。识别完成将识别结果发送回客户端。
  • 右边是客户端。main线程负责从摄像机采集视频,进行人脸检测,并将结果放入人脸队列中;同时负责从结果队列中取出人脸识别结果。 CFaceRecogTest类包装了TCPClient类,继承了线程类,在另一个线程中运行;其中的TCPClient类负责通信功能,包括从人脸队列中取得人脸数据并发送,接收服务端响应的结果数据并送入结果队列以提供给main线程,向向服务端定时发送心跳包。

algserver's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.