77范文网 - 专业文章范例文档资料分享平台

手机照相对战--嵌入式课程设计报告(3)

来源:网络收集 时间:2019-01-26 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

三.详细设计

3.1 系统数据结构

public class GameraGame extends Activity {

/** Called when the activity is first created. */

public class PhotoView extends Activity {

private static ImageSwitcher mSwitcher; private static Button returnButton; private static Button nextButton; private static Button resultButton; private static List phoList; private String newFilePath=\;

static List picFiles=new ArrayList(); private ImageView imageview; private ImageView imageafter; private static int picId=0; private String path; private Bitmap sourceBmp; private byte[] data; int width; int height; int num;

Camera camera; //camera

private CameraPreview preview; //camera view private Date today; //datetime private String fileName; // file name private SimpleDateFormat sdf=new

private Button sureBtn; //sure button private ImageView textview;

SimpleDateFormat(\);

//读取图像文件

private boolean FaceModel(int Cr,int Cb)

{

final double cx= 114.38; //Cb的系数常量 final double cy=160.02; //cr的系数常量 final double theta= 2.53;//角度常量

final double ecx=1.60;//x轴线和y轴线的两个常量 final double ecy=2.41; final double a=25.39;//长轴 final double b=14.03;//短轴

final double judge=0.5;//相似度常量

//计算得到x轴数值 double x = Math.cos(theta)*(Cb-cx)+Math.sin(theta)*(Cr-cy);

11

//y轴数值 double y = -Math.sin(theta)*(Cb -cx)+Math.cos(theta)*(Cr-cy); //计算离心率 double temp =

//如果满足要求返回真,否则假 if(Math.abs(temp-1.0)

return true; return false;

else

Math.pow(x-ecx,2)/Math.pow(a,2)+Math.pow(y-ecy,2)/Math.pow(b,2);

四.系统编码实现

4.1图像建模函数

//图像建模 private Bitmap test(Bitmap bmp)

{

width=bmp.getWidth(); height=bmp.getHeight(); int r,g,b=0;

int []pixel=new int[width*height]; flag=new boolean[height][width];

bmp.getPixels(pixel, 0, width, 0, 0, width, height); for(int i=0;i

for(int j=0;j

flag[i][j]=false;

for(int i=0;i

for(int j=0;j

for(int j=0;j

12

r=(pixel[i*width+j]>>16)&0xff; g=(pixel[i*width+j]>>8)&0xff; b=pixel[i*width+j]&0xff; if(r>95&&g>40&&b>20) {

if(Math.abs(r-g)>15||Math.abs(r-b)>15||Math.abs(g-b)>15)

}

{ }

if(Math.abs(r-g)>15&&r>g&&r>b)

flag[i][j]=true;

for(int i=0;i

{ }

if(flag[i][j]==true) { } else

r=g=b=0;

pixel[i*width+j]=0xff000000|(r<<16)|(g<<8)|b;

r=g=b=255;

bmp.setPixels(pixel, 0,width, 0, 0, width, height); return bmp; }

4.2摄像功能函数调用

class CameraPreview extends SurfaceView implements SurfaceHolder.Callback{

SurfaceHolder holder;

@Override

public void surfaceChanged(SurfaceHolder holder, int format, int

{ } else

parameters.setPictureSize(1024,786);

13

public CameraPreview(Context context) { }

super(context);

// TODO Auto-generated constructor stub holder=this.getHolder(); holder.addCallback(this);

holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

width,

int height) {

// TODO Auto-generated method stub try {

Camera.Parameters parameters=camera.getParameters(); //parameters.setPictureSize(width, height); parameters.setPictureFormat(PixelFormat.JPEG);

if(getWindowManager().getDefaultDisplay().getOrientation()==0)

parameters.setPreviewSize(height,width);

parameters.setPreviewSize(width, height);

{

}

{

camera.setParameters(parameters); camera.startPreview();

camera.autoFocus(new AutoFocusCallback() {

@Override

public void onAutoFocus(boolean success, Camera camera) );

// TODO Auto-generated method stub if(success) {

}catch(Exception e)

@Override

public void surfaceCreated(SurfaceHolder holder) { }

@Override

public void surfaceDestroyed(SurfaceHolder holder) { }

// TODO Auto-generated method stub camera.stopPreview(); camera.release(); camera=null;

// TODO Auto-generated method stub camera=Camera.open(); try{ }

camera.setPreviewDisplay(holder);

camera.release(); camera=null;

}catch(IOException e){

4.3 SD卡文件操作

private void checkMyStorage() {

if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))

14

{ } else{

new AlertDialog.Builder(this).setMessage(\检查到没有存储卡,请插入

手机存储卡再开启本应用\).setPositiveButton(\确定\, new DialogInterface.OnClickListener() {

@Override

public void onClick(DialogInterface dialog, int }

// TODO Auto-generated method stub finish();

if(new File(\).canRead()) { }

File file=new File(\); if(!file.exists()) { }

file.mkdir();

file=new File(\); file.mkdir();

which) {

}).show();

} }

private static List readFiles(String path)

{

File dir=new File(path); File[] files=dir.listFiles(); if(files!=null) {

for(int i=0;i

String fileName=files[i].getName(); if(fileName.lastIndexOf(\)>0&&

fileName.substring(fileName.lastIndexOf(\)+1,

fileName.length()).equals(\)||fileName.substring(fileName.las

{

picFiles.add(files[i].getPath()); 15

tIndexOf(\)+1,

fileName.length()).equals(\))

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库手机照相对战--嵌入式课程设计报告(3)在线全文阅读。

手机照相对战--嵌入式课程设计报告(3).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/445514.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: