/** * Calculate the dense * descriptors * * @param img The Source image * @param xystep Dense xy step size * * * @return Descriptors */ Mat Extractor::getDescriptors(Mat img, int xyStep) { Mat descriptors_mat; vector<KeyPoint> keypoints; SiftDescriptorExtractor sift_extractor; DenseFeatureDetector dense_detector(1.0f, 1, 0.1f, xyStep); img = initImg(img); dense_detector.detect(img, keypoints); sift_extractor.compute(img, keypoints, descriptors_mat); return descriptors_mat; }
int main(int ac, char **av) { if (ac < 3) return EXIT_SUCCESS; int w = atoi(av[1]); int h = atoi(av[2]); unsigned short **img = NULL; initImg(&img, w, h); drawLines(img, w, h); registerImage(img, w, h, "lines.jmc"); freeImg(img, h); return EXIT_SUCCESS; }
ERR_EXISTS executeQuery(Query *query, PixImg *in_img, PixImg *out_img, PixErr *err) { byte *selection_mask; QueryInit *init = &query->init; Number n; uint32 init_width; if(!evaluateExpression(&init->width,-1,-1,in_img,in_img,out_img,&n,err)) return ERR; if(n.type == NUMBER_TYPE_REAL) ERROR("Invalid width type"); init_width = n.i; uint32 init_height; if(!evaluateExpression(&init->height,-1,-1,in_img,in_img,out_img,&n,err)) return ERR; if(n.type == NUMBER_TYPE_REAL) ERROR("Invalid height type"); init_height = n.i; if(!in_img->data) { uint32 color; switch(init->type) { case QUERY_INIT_TYPE_COPY: ERROR("Target init type COPY, but no input file specified"); break; case QUERY_INIT_TYPE_WHITE: color = 0xFFFFFFFF; break; case QUERY_INIT_TYPE_BLACK: color = 0x000000FF; break; case QUERY_INIT_TYPE_CLEAR: color = 0x00000000; break; default: color = 0xFFFFFFFF; break; } if(!init_width || !init_height) ERROR("No input file nor init dimensions specified"); if(!initImg(in_img, init_width, init_height, color, err)) return ERR; } out_img->width = init_width; out_img->height = init_height; if(out_img->width == 0) out_img->width = in_img->width; if(out_img->height == 0) out_img->height = in_img->height; out_img->data = calloc(out_img->width*out_img->height*sizeof(Pix),1); if(!out_img->data) ERROR("Out of memory"); selection_mask = calloc(out_img->width*out_img->height*sizeof(byte),1); if(!selection_mask) ERROR("Out of memory"); switch(init->type) { case QUERY_INIT_TYPE_COPY: { for(int i = 0; i < out_img->height; i++) for(int j = 0; j < out_img->width; j++) *pixAt(out_img,j,i) = *pixAt(in_img,j,i); } break; case QUERY_INIT_TYPE_CLEAR: { for(int i = 0; i < out_img->height; i++) for(int j = 0; j < out_img->width; j++) set(pixAt(out_img,j,i),0,0,0,0); } break; case QUERY_INIT_TYPE_WHITE: { for(int i = 0; i < out_img->height; i++) for(int j = 0; j < out_img->width; j++) set(pixAt(out_img,j,i),255,255,255,255); } break; case QUERY_INIT_TYPE_BLACK: { for(int i = 0; i < out_img->height; i++) for(int j = 0; j < out_img->width; j++) set(pixAt(out_img,j,i),0,0,0,255); } break; case QUERY_INIT_TYPE_INVALID: default: //error break; } QueryProcedure *p = 0; QuerySelection *s = 0; QueryOperation *o = 0; PixImg *default_selecting = 0; PixImg *default_operating = 0; for(int i = 0; i < query->n_procedures; i++) { p = &query->procedures[i]; for(int j = 0; j < out_img->width*out_img->height; j++) selection_mask[j] = 0; for(int j = 0; j < p->n_selections; j++) { s = &p->selections[j]; switch(s->selecting) { case QUERY_TARGET_IN: default_selecting = in_img; break; case QUERY_TARGET_OUT: default_selecting = out_img; break; case QUERY_TARGET_FALLBACK: case QUERY_TARGET_INVALID: default: //error break; } for(int k = 0; k < out_img->height; k++) { for(int l = 0; l < out_img->width; l++) { if(!evaluateExpression(&s->exp,l,k,default_selecting,in_img,out_img,&n,err)) return ERR; if(n.type == NUMBER_TYPE_REAL && n.r != 0.0f) selection_mask[(k*out_img->width)+l] = 1; else if(n.type == NUMBER_TYPE_INT && n.i != 0) selection_mask[(k*out_img->width)+l] = 1; } } } for(int j = 0; j < p->n_operations; j++) { o = &p->operations[j]; switch(o->operating) { case QUERY_TARGET_IN: default_operating = in_img; break; case QUERY_TARGET_OUT: default_operating = out_img; break; case QUERY_TARGET_FALLBACK: case QUERY_TARGET_INVALID: default: ERROR("Invalid target"); break; } for(int k = 0; k < out_img->height; k++) for(int l = 0; l < out_img->width; l++) if(selection_mask[(k*out_img->width)+l]) if(!evaluateOperation(o,l,k,default_operating,in_img,out_img,err)) return ERR; } } free(selection_mask); return NO_ERR; }