diff options
| author | Leo Chan <leochanj@live.unc.edu> | 2020-10-22 01:53:21 -0400 |
|---|---|---|
| committer | Joshua Bakita <jbakita@cs.unc.edu> | 2020-10-22 01:56:35 -0400 |
| commit | d17b33131c14864bd1eae275f49a3f148e21cf29 (patch) | |
| tree | 0d8f77922e8d193cb0f6edab83018f057aad64a0 /SD-VBS/benchmarks/sift/src/c/script_sift.c | |
| parent | 601ed25a4c5b66cb75315832c15613a727db2c26 (diff) | |
Squashed commit of the sb-vbs branch.
Includes the SD-VBS benchmarks modified to:
- Use libextra to loop as realtime jobs
- Preallocate memory before starting their main computation
- Accept input via stdin instead of via argc
Does not include the SD-VBS matlab code.
Fixes libextra execution in LITMUS^RT.
Diffstat (limited to 'SD-VBS/benchmarks/sift/src/c/script_sift.c')
| -rw-r--r-- | SD-VBS/benchmarks/sift/src/c/script_sift.c | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/sift/src/c/script_sift.c b/SD-VBS/benchmarks/sift/src/c/script_sift.c new file mode 100644 index 0000000..0b2f106 --- /dev/null +++ b/SD-VBS/benchmarks/sift/src/c/script_sift.c | |||
| @@ -0,0 +1,83 @@ | |||
| 1 | /******************************** | ||
| 2 | Author: Sravanthi Kota Venkata | ||
| 3 | ********************************/ | ||
| 4 | |||
| 5 | #include <stdio.h> | ||
| 6 | #include <stdlib.h> | ||
| 7 | #include "sift.h" | ||
| 8 | #include <malloc.h> | ||
| 9 | #include "extra.h" | ||
| 10 | #define SIFT_MEM 1<<29 | ||
| 11 | void normalizeImage(F2D* image) | ||
| 12 | { | ||
| 13 | int i; | ||
| 14 | int rows; | ||
| 15 | int cols; | ||
| 16 | |||
| 17 | int tempMin = 10000, tempMax = -1; | ||
| 18 | rows = image->height; | ||
| 19 | cols = image->width; | ||
| 20 | |||
| 21 | for(i=0; i<(rows*cols); i++) | ||
| 22 | if(tempMin > asubsref(image,i)) | ||
| 23 | tempMin = asubsref(image,i); | ||
| 24 | |||
| 25 | for(i=0; i<(rows*cols); i++) | ||
| 26 | asubsref(image,i) = asubsref(image,i) - tempMin; | ||
| 27 | |||
| 28 | for(i=0; i<(rows*cols); i++) | ||
| 29 | if(tempMax < asubsref(image,i)) | ||
| 30 | tempMax = asubsref(image,i); | ||
| 31 | |||
| 32 | for(i=0; i<(rows*cols); i++) | ||
| 33 | asubsref(image,i) = ( asubsref(image,i) / (tempMax+0.0) ); | ||
| 34 | } | ||
| 35 | |||
| 36 | int main(int argc, char* argv[]) | ||
| 37 | { | ||
| 38 | SET_UP | ||
| 39 | mallopt(M_TOP_PAD, SIFT_MEM); | ||
| 40 | mallopt(M_MMAP_MAX, 0); | ||
| 41 | I2D* im; | ||
| 42 | F2D *image; | ||
| 43 | int rows, cols, i, j; | ||
| 44 | F2D* frames; | ||
| 45 | unsigned int* startTime, *endTime, *elapsed; | ||
| 46 | |||
| 47 | char imSrc[100]; | ||
| 48 | printf("Input image: "); | ||
| 49 | scanf("%s", imSrc); | ||
| 50 | im = readImage(imSrc); | ||
| 51 | image = fiDeepCopy(im); | ||
| 52 | rows = image->height; | ||
| 53 | cols = image->width; | ||
| 54 | |||
| 55 | |||
| 56 | printf("start\n"); | ||
| 57 | for_each_job{ | ||
| 58 | image = fiDeepCopy(im); | ||
| 59 | normalizeImage(image); | ||
| 60 | /** Extract sift features for the normalized image **/ | ||
| 61 | frames = sift(image); | ||
| 62 | } | ||
| 63 | printf("end..\n"); | ||
| 64 | |||
| 65 | #ifdef CHECK | ||
| 66 | { | ||
| 67 | int ret=0; | ||
| 68 | float tol = 0.2; | ||
| 69 | #ifdef GENERATE_OUTPUT | ||
| 70 | fWriteMatrix(frames, argv[1]); | ||
| 71 | #endif | ||
| 72 | ret = fSelfCheck(frames, "expected_C.txt", tol); | ||
| 73 | if (ret == -1) | ||
| 74 | printf("Error in SIFT\n"); | ||
| 75 | } | ||
| 76 | #endif | ||
| 77 | |||
| 78 | iFreeHandle(im); | ||
| 79 | fFreeHandle(frames); | ||
| 80 | WRITE_TO_FILE | ||
| 81 | return 0; | ||
| 82 | } | ||
| 83 | |||
