CUDA or GPU shader image comparison (learn and earn series)
$100-200 USD
In Progress
Posted almost 14 years ago
$100-200 USD
Paid on delivery
I need a bitmap comparison class that will utilize CUDA or GPU shaders on graphic cards to achieve maximum paralel performance.
Class should be made usable from c# interface.
## Deliverables
Purpose of software component for image comparison is video scene search. ? In order to do that, it is imperative that many comparison operations will be computed in as short time as possible. ? I have reference application that uses CPU for comparison, but practical application for it is impossible, since it is too slow.
Software component should work in several phases, and here is the explanation of that phases:
1. Card Probing
Component should be able to probe GPU so it can know various stuff about it - memory available, GPU architecture, ...
2. Setup
Component should be informed in what format the BITMAPs will be given - format should be determined by bitmap size. ? Component should also be given instruction about internal representation of the bitmap on the GPU - it could be RGB24 or RGB565.
Comparison theshold will be given at this time.
3. Images upload
Multiple images should be uploaded and stored on the GPU. ? Component should report how many images can be uploaded further. ? Images should be rescaled/converted to target size/colorspace if necessery.
4. Comparison of single VS bunch of images
One image for comparison against all of the images will be given, and in one instruction result vector should be given back giving the results of the comparison.
5. Step 4 will be run again and again, preserving uploaded bunch of the images made in step 3.
6. Step 3 will be used to upload new bunch of images to the card, and whole process will be repeated.
Some method propositions:
/// for setting the destination image format
void SetImageFormat(int Width, int Height, ColorFormat Format);
/// for setting the comparison treshold
void SetTreshold(float Treshold);
/// for uploading the picture (from the picture bunch)
void UploadPicture(Bitmap Pic);
/// for determining available picture memory
int RemainingPictureSlotsAvailable();
/// for actual comparison
float[] ComparePicture(Bitmap PictureToCompare);
Result of the picture comparation for each picture pair is averaged RGB space distance of every pixel on the two images.
Two pixels of RGB(0,0,0) have distance of 0.0
Pixels of RGB(0,0,0) and RGB(255,255,255) have distance of 1.0
Comparation treshold is cumulative average value that determines the bailout for the comparation. ? If during the pixel comparison current value goes above the treshold value, comparison is aborted and current value returned (which will be same or a little above the threshold value).
Everything should be wrapped in c# casing, making it usable from .net environment.
I will perform the testing by integrating the component in larger system that will run stated comparisons. ? Both accuracy and speed will be measured.
**One observation regarding speed**
**
**
**I find that using CUDA will greatly improve the speed of multiple comparisons, because of the following.**
on-CPU comparison:
To compare one image against 100 of them, you have to spend time 100U (let's say that U is time to compare one image against another)
If you make 90.000 iterations of it (for one hour video that's the number of frames) you'll get 9.000.000U
on GPU comparison
To upload 100 images you'll use 100U again (providing that what you said about comparison and upload speed is true) - and will do that one time only for say one hour of video.
In each of 90.000 iterations you'll use 1U to upload current frame, and unknown number of Us to compare that frame to the frames already on the GPU.
So, the fact is that comparations should run in parallel on GPU so each frame comparation is done in far less then 100U. ? Let's say it can be done in 10U.
1U (for upload of the frame) + 10U for comparison = 11U
100U (first bunch upload) + 90.000x11U = 990.100U
And that is 9x faster than the original on-CPU comparison.
But I guess that 100 comparisons could be made even faster utilizing parallel nature of the GPU processors.