MCPcopy Create free account
hub / github.com/CRVI/OpenCLIPP / main

Function main

Demo/Demo.cpp:36–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34
35
36int main(int /*argc*/, char ** /*argv*/)
37{
38 // Load image from file
39 string FileName = "lena.png";
40
41 SImage ImageInfo;
42 vector<unsigned char> SourceData, ResultData;
43
44 unsigned Status = lodepng::decode(SourceData, ImageInfo.Width, ImageInfo.Height, FileName, LCT_RGB);
45
46 if (Status == 0)
47 {
48 // Load image from file succeded
49 ImageInfo.Channels = 3;
50 ImageInfo.Type = SImage::U8;
51 ImageInfo.Step = CalculateStep(ImageInfo);
52 }
53 else
54 {
55 // Load image from file failed
56 printf("Unable to open file lena.png - using empty image\n");
57
58 ImageInfo.Channels = 3;
59 ImageInfo.Type = SImage::U8;
60 ImageInfo.Width = 512;
61 ImageInfo.Height = 512;
62 ImageInfo.Step = CalculateStep(ImageInfo);
63 SourceData.resize(ImageInfo.Height * ImageInfo.Step);
64 }
65
66 ResultData.resize(SourceData.size());
67
68
69 // Initialize OpenCL
70 COpenCL CL;
71 CL.SetClFilesPath("D:/OpenCLIPP/cl-files/");
72 Filters Filters(CL);
73
74 // Display device name
75 string Name = CL.GetDeviceName();
76 printf("Using device : %s\n", Name.c_str());
77
78 // Create images in OpenCL device
79 ColorImage SourceImage(CL, ImageInfo, SourceData.data());
80 ColorImage ResultImage(CL, ImageInfo, ResultData.data());
81
82 SourceImage.Send(); // Optional : Sends image to device memory - would be done automatically
83
84
85 // Execute filter
86 Filters.Sobel(SourceImage, ResultImage);
87
88
89 // Read image to main memory
90 ResultImage.Read(true);
91
92
93 // Save image to new file

Callers

nothing calls this directly

Calls 8

SetClFilesPathMethod · 0.80
GetDeviceNameMethod · 0.80
SobelMethod · 0.80
CalculateStepFunction · 0.70
decodeFunction · 0.50
encodeFunction · 0.50
SendMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected