基于ARM9TDMI的指纹识别主程序

源代码在线查看: myself.cpp

软件大小: 3 K
上传用户: budyang
关键词: ARM9TDMI 指纹识别 程序
下载地址: 免注册下载 普通下载 VIP

相关代码

				//采用HOUGH变换实现指纹特征提取
				
				
				
				extern "C"
				{
				#include "fvs.h"
				#include 
				}
				
				#include 
				#include 
				#include 
				#include 
				using namespace std;
				
				static FvsError_t OverlayDirection(FvsImage_t image, const FvsFloatField_t field)
				{
				    FvsError_t nRet = FvsOK;
				    FvsInt_t w      = ImageGetWidth (image);
				    FvsInt_t h      = ImageGetHeight(image);
				    FvsInt_t pitch, dirp;
				    FvsFloat_t theta, c, s;
				    FvsByte_t* p;
				    FvsFloat_t* orientation;
				    FvsInt_t x, y, size, i, j, l;
				
				    size = 8; 
				
				    (void)ImageLuminosity(image, 168);
				
				    pitch  = ImageGetPitch (image);
				    p      = ImageGetBuffer(image);
				
				    orientation = FloatFieldGetBuffer(field);
				    dirp        = FloatFieldGetPitch(field);
				
				    if (p==NULL || orientation==NULL)
				        return FvsMemory;
				
				    for (y = size; y < h-size; y+=size-2)
				    for (x = size; x < w-size; x+=size-2)
				    {
				        theta = orientation[x+y*dirp];
				        c = cos(theta);
				        s = sin(theta);
				        
				        for (l = 0; l < size; l++)
				        {
				            i = (FvsInt_t)(x + size/2 - l*s);
				            j = (FvsInt_t)(y + size/2 + l*c);
				            p[i+j*pitch] = 0;
				        }
				    }
				    return nRet;
				}
				
				int main(int argc, char *argv[])
				{
					FvsImage_t mask;
				    FvsImage_t ridgeimage;
				    FvsImage_t valleyimage;
				    FvsFloatField_t direction;
				    FvsFloatField_t frequency;
				    FvsByte_t highsize = 110;
				    FvsByte_t lowsize = 90;
					FvsByte_t bmfh[14];
					BITMAPINFOHEADER bmih;
					RGBQUAD			rgbq[256];
					clock_t		start,finish;
					
				   if (argc4)
				    {
				        printf("Usage: fvs input.bmp [highsize] [lowsize]\n");
				        return -1;
				    }
				    if (argc==3)
				       highsize = (FvsByte_t)atoi(argv[2]);
				    if (argc==4)
					{
						highsize = (FvsByte_t)atoi(argv[2]);
						lowsize = (FvsByte_t)atoi(argv[3]);
					}
				
					mask      = ImageCreate();
				    ridgeimage     = ImageCreate();
					valleyimage     = ImageCreate();
				    direction = FloatFieldCreate();
				    frequency = FloatFieldCreate();
				
				    if (mask!=NULL && ridgeimage!=NULL && direction!=NULL && frequency!=NULL && valleyimage!=NULL)
				    {
					   fprintf(stdout, "Opening file %s...\n", argv[1]);
					   if(FvsOK!= FvsImageImport(ridgeimage, argv[1],bmfh,&bmih,rgbq))
					        return -1 ;
					    
					   FvsInt_t w      = ImageGetWidth (ridgeimage);
						FvsInt_t h      = ImageGetHeight(ridgeimage);
						ImageSetSize(valleyimage, w, h);
				
						ImageSoftenMean(ridgeimage, 3);
						ImageNormalize(ridgeimage, 100, 10000);
				
				        fprintf(stdout, "Binarizing image\n");
						MyImageBinarize(ridgeimage,valleyimage,highsize,lowsize);
				
				/*		start=clock();
				        (void)FingerprintGetDirection(image, direction, 7, 8);
						finish=clock();
						cout				
				        fprintf(stdout, "2/4 Determining the ridge frequency\n");
						start=clock();       
						(void)FingerprintGetFrequency(image, direction, frequency);
						finish=clock();
						cout				
				        fprintf(stdout, "3/4 Creating the mask\n");
						start=clock(); 
				        (void)FingerprintGetMask(image, direction, frequency, mask);
						finish=clock();
						cout				
				        fprintf(stdout, "4/4 Enhancing the fingerprint image\n");
				        start=clock();
						(void)ImageEnhanceGabor(image, direction, frequency, NULL, radius);
						finish=clock();
						cout				
				        fprintf(stdout, "Creating a new image with the direction\n");
				        (void)OverlayDirection(directionimage, direction);
				
						fprintf(stdout, "Saving file ...\n");
						strcpy(filename,argv[1]);		
						 strcat(filename,"_dir.bmp"); */
				        (void)FvsImageExport(ridgeimage,"d:\\temp\\13_5ridge.bmp",bmfh,&bmih,rgbq);
				
						(void)FvsImageExport(valleyimage,"d:\\temp\\13_5valley.bmp",bmfh,&bmih,rgbq);        
				
				    }
				    fprintf(stdout, "Cleaning up and exiting...\n");
				    FloatFieldDestroy(frequency);
				    FloatFieldDestroy(direction);
				    ImageDestroy(ridgeimage);
				    ImageDestroy(mask);
				    ImageDestroy(valleyimage);
				
				    return 0;
				}
							

相关资源