三.详细设计
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
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 { 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)在线全文阅读。
相关推荐: