
![]() mailto, against spam! Problems with Mac OS XComputer · 27. Juni 2011 21:39
steps 2-5 have to be done after every power-on Tags: apple · mac · mac os · mac os x · problem Trolldetection with opencv (#gpn11 release)Computer · 25. Juni 2011 12:09 · 3 Kommentare it detects faces and puts trollface there ![]() trollface_before
![]() trollface_after
1 #include <stdlib.h> 2 #include <stdio.h> 3 #include <math.h> 4 #include <cv.h> 5 #include <highgui.h> 6 7 void draw(IplImage *img, int x, int y, int width, int height) 8 { 9 IplImage* troll = cvLoadImage("trollface.png", CV_LOAD_IMAGE_COLOR); 10 IplImage* scale_troll = cvCreateImage(cvSize(width, height), img->depth, 11 img->nChannels); 12 13 cvSetImageROI(img, cvRect(x,y,scale_troll->width,scale_troll->height)); 14 cvResize(troll, scale_troll, CV_INTER_LINEAR); 15 cvAddWeighted(img, 0.0, scale_troll, 1.0, 0.5, img); 16 cvResetImageROI(img); 17 18 cvReleaseImage(&troll); 19 cvReleaseImage(&scale_troll); 20 21 } 22 23 int main(int argc, char *argv[]) 24 { 25 int i; 26 double scale; 27 IplImage* img; 28 CvHaarClassifierCascade* cascade; 29 CvSeq* faces; 30 CvRect* r; 31 CvMemStorage* storage = cvCreateMemStorage(0); 32 33 cvClearMemStorage(storage); 34 35 if (argc<2) 36 { 37 printf("Usage: main <image-file-name>\n\7"); 38 exit(0); 39 } 40 41 cascade = (CvHaarClassifierCascade*)cvLoad( 42 "/usr/share/opencv/haarcascades/haarcascade_frontalface_default. 43 xml", 0, 0, 0 ); 44 //cascade = (CvHaarClassifierCascade*)cvLoad( 45 "/usr/share/opencv/haarcascades/haarcascade_frontalface_alt. 46 xml", 0, 0, 0 ); 47 48 49 img=cvLoadImage(argv[1], CV_LOAD_IMAGE_COLOR); 50 if (!img) 51 { 52 printf("Could not load image file: %s\n",argv[1]); 53 exit(-1); 54 } 55 56 printf("Processing a %dx%d image with %d channels\n",img->width,img-> 57 height,img->nChannels); 58 59 cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE); 60 //cvMoveWindow("mainWin", 100, 100); 61 62 if (!cascade) 63 fprintf(stderr, "ERROR, no cascade loaded :(\n"); 64 65 scale = 1+((43e-8)*img->width*img->height); 66 printf("scale: %f\n", scale); 67 68 faces = cvHaarDetectObjects( img, cascade, storage, scale, 3, 69 CV_HAAR_DO_CANNY_PRUNING, cvSize(40,40), cvSize(50,50) ); 70 //faces = cvHaarDetectObjects( img, cascade, storage, scale, 3, 71 CV_HAAR_SCALE_IMAGE, cvSize(40,40), cvSize(50,50) ); 72 for ( i = 0; i < (faces ? faces->total : 0); i++ ) 73 { 74 cvShowImage("mainWin", img ); 75 cvWaitKey(0); 76 77 printf("face\n"); 78 r = (CvRect*)cvGetSeqElem(faces, i); 79 //cvRectangle(img, cvPoint( r->x, r->y ), cvPoint( r->x + r->width, r- 80 >y + r->height ), colors[i%8], 5, 8, 0); 81 draw(img, r->x, r->y, r->width, r->height); 82 } 83 cvShowImage("mainWin", img ); 84 85 cvWaitKey(0); 86 cvSaveImage("Result.jpg", img, 0); 87 88 cvReleaseImage(&img); 89 cvDestroyWindow("mainWin"); 90 return 0; 91 } Makefile: gcc troll.c -o troll -lm -lopencv_highgui -lopencv_objdetect -I /usr/include/opencv/ -Wall -g Tags: ansi c · computer vision · detection · face · facedetection · opencv · trollface · vision 08. Juni 2011Sonstiges · 08. Juni 2011 13:20 · 3 Kommentare Club mate and ice-t now available in passau diagonally opposite wiwi faculty ![]() Tags: mobil Download your fav pics from flickrTechnologie / Wissenschaft · 05. Juni 2011 02:16 · 1 Kommentar Imagine you have faved a lot of pics on flickr and now want to download them; of course you could do that easy in perl - BUT you can do this easy in C, too Some Presteps:
1 #include <stdio.h> 2 #include <flickcurl.h> 3 4 #define USERNSS "63169079@N05" 5 #define MAX_PAGES 500 6 7 int main() 8 { 9 int i, page; 10 char *url; 11 12 flickcurl *fc; 13 flickcurl_photos_list *pl; 14 flickcurl_photos_list_params list_params; 15 16 flickcurl_init(); 17 18 fc = flickcurl_new(); 19 20 flickcurl_set_api_key(fc, "..."); 21 flickcurl_set_shared_secret(fc, "..."); 22 flickcurl_set_auth_token(fc, "..."); 23 24 flickcurl_photos_list_params_init(&list_params); 25 list_params.per_page = 10; 26 list_params.page = 0; 27 for (page = 0; page < MAX_PAGES; page++) 28 { 29 printf("page: %d\n", page); 30 list_params.page = page; 31 32 list_params.extras = "original_format"; 33 pl = flickcurl_favorites_getList_params(fc, USERNSS, &list_params); 34 for (i = 1; i < pl->photos_count; ++i) 35 { 36 printf(" Result #%d has ID %s ", i, pl->photos[i]->id); 37 url = flickcurl_photo_as_source_uri(pl->photos[i], 'b'); 38 printf(" | url: %s\n", url); 39 free(url); 40 } 41 flickcurl_free_photos_list(pl); 42 if (pl->photos_count == 0) 43 break; 44 } 45 46 flickcurl_free(fc); 47 flickcurl_finish(); 48 } Insert correctly the values you got via presteps: 1 flickcurl_set_api_key(fc, "..."); 2 flickcurl_set_shared_secret(fc, "..."); 3 flickcurl_set_auth_token(fc, "..."); you can find these values in ~/.flickcurl. You can find out your correctly USERNSS when you go to your flickr-favorites; now look at the URL (e.g. http://www.flickr.com/photos/63169079@N05/favorites/) Now compile: P.S.: explore flickr via pandas: http://www.flickr.com/explore/panda Tags: ansi c · curl · flickcurl · flickr · images |
Einträge anzeigen
Jahr 2012 (3) AbonnierenTags |