最新公告:

中华视窗是诚信为本,市场在变,我们的诚信永远不变...

中华视窗

咨询热线

400-123-4657

公司动态

当前位置: 首页 > 新闻动态 > 公司动态

计算机毕设 - 基于Android的人脸门禁系统

添加时间:2024-01-23

/

文章目录

0 项目说明

基于的人脸门禁系统

提示:适合用于课程设计或毕业设计,工作量达标,源码开放

1 研究目的

传统的门禁系统以钥匙作为验证手段,便捷程度低,丢失钥匙之后会导致极大的安全问题。人脸是一种极易获得的生物特征,具有唯一性、稳定性的特点,并且使用时设备无需与人脸接触,因此可以作为新一代的门禁验证手段。近年来,随着移动设备性能的不断提升,使得在移动设备上进行人脸识别成为可能。本repo设计并开发了一个基于平台的人脸识别门禁系统,并解决了在实际运用中可能遇到的光照变化,人脸姿态变化等情况。

2 研究内容及实验结果

1)基于双眼检测的正脸判断算法研究。人脸识别中,人脸的姿态变化会导致识别率降低。首先研究实现了基于Haar特征的人脸检测算法,检测定位出人脸的框架和双眼的位置。然后通过人脸与双眼的位置关系,提出了一个正脸判断的方法。实验表明,该方法有效地降低了人脸姿态问题对于整个识别系统的影响。

2)基于LBP+PCA的人脸识别算法研究。首先分析了局部二值模式LBP和主成份分析PCA的原理,研究了LBP与PCA相结合的特征提取方法。相对于单独使用PCA方法,该组合方法能够有效地降低光照变化对人脸识别准确度的影响。然后,采用支持向量机对特征进行分类,并利用置信度计算方法,来有效地表示人脸和分类结果的隶属程度。实验表明,该算法对于光照变化情况下的人脸识别,准确率有了明显的提升。

3)平台上人脸识别门禁系统的设计与实现。分析了系统的需求,设计了具有用户注册、人脸检测与识别、门禁开关、管理员模块、通知模块等功能模块的人脸识别门禁系统。然后在平台上,利用Java语言和计算机图像视觉库,按照软件工程逻辑完成了系统的整体开发。整个系统经过测试运行,能够满足典型环境中的使用需求。

3 部分系统界面

动态人脸识别门禁系统公司_动态人脸识别考勤门禁机_人脸识别门禁产品

用户主界面

识别界面

识别成功界面

用户管理页面

4 项目源码

package org.opencv.android;
import java.io.IOException;
import java.util.List;
import android.annotation.TargetApi;
import android.hardware.Camera;
import android.hardware.Camera.Size;
import android.os.Build;
import android.util.Log;
@TargetApi(15)
@SuppressWarnings("deprecation")
public class CameraRenderer extends CameraGLRendererBase {
    public static final String LOGTAG = "CameraRenderer";
    private Camera mCamera;
    private boolean mPreviewStarted = false;
    CameraRenderer(CameraGLSurfaceView view) {
        super(view);
    }
    @Override
    protected synchronized void closeCamera() {
        Log.i(LOGTAG, "closeCamera");
        if(mCamera != null) {
            mCamera.stopPreview();
            mPreviewStarted = false;
            mCamera.release();
            mCamera = null;
        }
    }
    @Override
    protected synchronized void openCamera(int id) {
        Log.i(LOGTAG, "openCamera");
        closeCamera();
        if (id == CameraBridgeViewBase.CAMERA_ID_ANY) {
            Log.d(LOGTAG, "Trying to open camera with old open()");
            try {
                mCamera = Camera.open();
            }
            catch (Exception e){
                Log.e(LOGTAG, "Camera is not available (in use or does not exist): " + e.getLocalizedMessage());
            }
            if(mCamera == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
                boolean connected = false;
                for (int camIdx = 0; camIdx < Camera.getNumberOfCameras(); ++camIdx) {
                    Log.d(LOGTAG, "Trying to open camera with new open(" + camIdx + ")");
                    try {
                        mCamera = Camera.open(camIdx);
                        connected = true;
                    } catch (RuntimeException e) {
                        Log.e(LOGTAG, "Camera #" + camIdx + "failed to open: " + e.getLocalizedMessage());
                    }
                    if (connected) break;
                }
            }
        } else {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
                int localCameraIndex = mCameraIndex;
                if (mCameraIndex == CameraBridgeViewBase.CAMERA_ID_BACK) {
                    Log.i(LOGTAG, "Trying to open BACK camera");
                    Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
                    for (int camIdx = 0; camIdx < Camera.getNumberOfCameras(); ++camIdx) {
                        Camera.getCameraInfo( camIdx, cameraInfo );
                        if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
                            localCameraIndex = camIdx;
                            break;
                        }
                    }
                } else if (mCameraIndex == CameraBridgeViewBase.CAMERA_ID_FRONT) {
                    Log.i(LOGTAG, "Trying to open FRONT camera");
                    Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
                    for (int camIdx = 0; camIdx < Camera.getNumberOfCameras(); ++camIdx) {
                        Camera.getCameraInfo( camIdx, cameraInfo );
                        if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
                            localCameraIndex = camIdx;
                            break;
                        }
                    }
                }
                if (localCameraIndex == CameraBridgeViewBase.CAMERA_ID_BACK) {
                    Log.e(LOGTAG, "Back camera not found!");
                } else if (localCameraIndex == CameraBridgeViewBase.CAMERA_ID_FRONT) {
                    Log.e(LOGTAG, "Front camera not found!");
                } else {
                    Log.d(LOGTAG, "Trying to open camera with new open(" + localCameraIndex + ")");
                    try {
                        mCamera = Camera.open(localCameraIndex);
                    } catch (RuntimeException e) {
                        Log.e(LOGTAG, "Camera #" + localCameraIndex + "failed to open: " + e.getLocalizedMessage());
                    }
                }
            }
        }
        if(mCamera == null) {
            Log.e(LOGTAG, "Error: can't open camera");
            return;
        }
        Camera.Parameters params = mCamera.getParameters();
        List<String> FocusModes = params.getSupportedFocusModes();
        if (FocusModes != null && FocusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO))
        {
            params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
        }
        mCamera.setParameters(params);
        try {
            mCamera.setPreviewTexture(mSTexture);
        } catch (IOException ioe) {
            Log.e(LOGTAG, "setPreviewTexture() failed: " + ioe.getMessage());
        }
    }
    @Override
    public synchronized void setCameraPreviewSize(int width, int height) {
        Log.i(LOGTAG, "setCameraPreviewSize: "+width+"x"+height);
        if(mCamera == null) {
            Log.e(LOGTAG, "Camera isn't initialized!");
            return;
        }
        if(mMaxCameraWidth  > 0 && mMaxCameraWidth  < width)  width  = mMaxCameraWidth;
        if(mMaxCameraHeight > 0 && mMaxCameraHeight < height) height = mMaxCameraHeight;
        Camera.Parameters param = mCamera.getParameters();
        List<Size> psize = param.getSupportedPreviewSizes();
        int bestWidth = 0, bestHeight = 0;
        if (psize.size() > 0) {
            float aspect = (float)width / height;
            for (Size size : psize) {
                int w = size.width, h = size.height;
                Log.d(LOGTAG, "checking camera preview size: "+w+"x"+h);
                if ( w <= width && h <= height &&
                     w >= bestWidth && h >= bestHeight &&
                     Math.abs(aspect - (float)w/h) < 0.2 ) {
                    bestWidth = w;
                    bestHeight = h;
                }
            }
            if(bestWidth <= 0 || bestHeight <= 0) {
                bestWidth  = psize.get(0).width;
                bestHeight = psize.get(0).height;
                Log.e(LOGTAG, "Error: best size was not selected, using "+bestWidth+" x "+bestHeight);
            } else {
                Log.i(LOGTAG, "Selected best size: "+bestWidth+" x "+bestHeight);
            }
            if(mPreviewStarted) {
                mCamera.stopPreview();
                mPreviewStarted = false;
            }
            mCameraWidth  = bestWidth;
            mCameraHeight = bestHeight;
            param.setPreviewSize(bestWidth, bestHeight);
        }
        param.set("orientation", "landscape");
        mCamera.setParameters(param);
        mCamera.startPreview();
        mPreviewStarted = true;
    }
}

5 最后

联系我们

电话:400-123-4657

传真:+86-123-4567

地址:浙江 温州市 温州大道欧江大厦26188号

邮箱:admin@nxdls.net

电话:400-123-4657 传真:+86-123-4567 地址:浙江 温州市 温州大道欧江大厦26188号
版权所有:Copyright © 2002-2024 中华视窗 版权所有 非商用版本 ICP备案编号:粤IP**********    网站地图