Home | Develop | Download | Contact
example_dic1.c
1 /*
2  * example_dic1.c
3  *
4  * Copyright 2018 Fernando Pujaico Rivera <fernando.pujaico.rivera@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  * MA 02110-1301, USA.
20  *
21  */
22 
32 #include <stdlib.h>
33 #include <pds/pdsra.h>
34 #include <pds/pdsdic.h>
35 #include <time.h>
36 
37 int main(int argc, char** argv)
38 {
39  int ID=0;
40 
41  // Creating two matrix with only delocated region
42  PdsMatrix *M0=pds_matrix_new_rand(600,800);
43  PdsMatrix *M1=pds_matrix_new_rand(600,800);
44 
45  PdsRegionRect R0=pds_region_rect(50,250,48,64);
46  PdsRegionRect R1=pds_region_rect_transfer(R0,64,64);
47 
48  pds_matrix_init_region(M0,R0,0.0);
49  pds_matrix_init_region(M1,R1,0.0);
50 
51  pds_region_rect_stylized_printf(R0);
52  pds_region_rect_stylized_printf(R1);
53 
54  // Creating a DIC structure and tracking the region
55 
57  if(DIC==NULL) return EXIT_FAILURE;
58 
59  PdsRegionRect R;
60 
61  int N=10;
62  clock_t time_init = clock ();
63  for(int i=0;i<N;i++) ID=pds_dic2d_tracking_region(DIC,R0,&R);
64  clock_t time_end = clock ();
65  printf("Calculating using %f seconds by point\n",(time_end-time_init)/(N*CLOCKS_PER_SEC*1.0));
66  printf("last_match_corr: %f\n",DIC->last_match_corr);
67 
68 
69  if(ID==PDS_DIC2D_FOUND) pds_region_rect_stylized_printf(R);
70  if(ID==PDS_DIC2D_NOFOUND) printf("FAIL: Region no found.\n");
71  if(ID==PDS_DIC2D_ERROR) printf("ERROR: in tracking.\n");
72 
73  pds_matrix_mul_value(DIC->M0,255.0);
74  pds_matrix_mul_value(DIC->M1,255.0);
75  pds_matrix_save_bmp_with_grayscale(DIC->M0,"imagedicm0.bmp");
76  pds_matrix_save_bmp_with_grayscale(DIC->M1,"imagedicm1.bmp");
77 
78  // releasing the memory of DIC structure
79  pds_dic2d_free(DIC);
80 
81  return EXIT_SUCCESS;
82 }
La estructura tipo PdsDic2D . Esta estructura contiene dos matrices de Nlin lineas y Ncol columnas...
Definition: pdsdic2d.h:127
int pds_dic2d_tracking_region(PdsDic2D *DIC, PdsRegionRect Rin, PdsRegionRect *Rout)
Devuelve la región coincidente en la segunda matriz.
PdsRaReal last_match_corr
Definition: pdsdic2d.h:152
void pds_dic2d_free(PdsDic2D *DIC)
Libera la estructura de tipo puntero PdsDic2D.
PdsMatrix * M1
Definition: pdsdic2d.h:132
PdsMatrix * M0
Definition: pdsdic2d.h:130
PdsDic2D * pds_dic2d_new_from_matrices(const PdsMatrix *Mat0, const PdsMatrix *Mat1)
Crea una estructura de tipo PdsDic2D, internamente la estructura contiene una copia de las dos matric...

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed