Inspiration
My manager asked me a question related to color based decision making. But at that time i was unsure if i could solve it. so I tried hard and came up with this custom activity.
What it does
- This custom activity offers these features:
[1] Extract color from any pixel on the screen
[2] Extract colors from image datatype
[3] Extract colors from image file
- There are two color scheme used in this activity:
[1] PrimaryColor - predefined enum consists of 12 primary colors
[2] KnownColor - Default Color enum in System.Drawing
How I built it
- Visual studio : to build the code in C#.
- Known color of Window forms : to identify the RBG color.
- Euclidean distance formula : to identify the nearest color to a given RBG color.
- Uipath Get Position activity : to get the position of the element.
Challenges I ran into
KnownColor type in C# includes unnecessary window form specific RBG colors which were not required. Initially I created an array of window specific colors and used it to ignore these colors from output. But it was not a neat solution. So I found a function known.IsSystemColor to achieve the same task.
It was difficult to find out which XY coordinate was getting selected while identifying the color from screen. So I used a Pen in System.Drawing to create an eclipse before identifying the color. It is very useful for debugging.
As KnownColor enum has 167 colors, so it was difficult to get the correct primary color as outcome. So I created an enum of 12 primary colors to produce correct output.
Accomplishments that I'm proud of
- Beta version of this activity is being used in couple of projects and I have received good feedback from UiPath developer community. I am glad that it is helpful in performing color based decision making.
What I learned
- Windows graphics : To draw objects on screen
- Code Activity : To built custom activities for UiPath
- Code reusability : To reuse the common code between multiple activities
What's next for Color Detector
Improving accuracy: As it is using distance formula to identify nearest RBG coordinate so, there are some chances that it can identify an incorrect color. Therrfore I want to improve its accuracy so that it can produce better results.
Adding more color based activities like adding colors on images, drawing shapes or adding watermark on images
Built With
- custom-activity
- euclid
- uipath
- visual-studio
Log in or sign up for Devpost to join the conversation.