How to Specify Product Quantity Of Multiple Options in Opencart - opencart

I am having a little but pretty serious problem with opencart inventory control.
Lets say I have a Shirt with 3 colors (Red, Black, White) and 3 sizes (S, M, L) and want to specify quantity for each size and color so, when Red in S is sold old, it should only deduct 1 from Red and not the whole stock/option.
I hope you got my point.
Thank you

That's not possible in the way you described with OpenCart out of the box. You'll either need a third party extension or you need to structure your options explicitly like:
Red S
Red M
Red L
Black S
Black M
Black L
White S
White M
White L
This way you can specify stock amounts for each one and disable them as needed when out of stock.

Related

How can I use different colors for different labels in TensorBoard embedding visualization?

I am visualizing sentence embedding using tensorboard. I have label for each sentence embedding. How can I set a color for each label?
For example
embedding vector Labels
[0.2342 0.2342 0.234 0.8453] A
[0.5342 0.9342 0.234 0.1453] B
[0.7342 0.0342 0.124 0.8453] C
[0.8342 0.5342 0.834 0.5453] A
I am able to visualize the embedding vector where each row is labeled by its label. I want to set colors also so that I see points with same label will have same color. Like all "A" will be red, "B" will be green, "C" will be blue and so on?
I searched on Google but didn't get any sample.
Could anyone please share some code to get it done?
Thank you in advanced.
There should be a colour by drop down that you can use.
In case that is not showing up, one of the possible reason could be that you have more than 50 unique labels, which is the hardcoded limit in the current tensorflow code.
Refer to this thread for details.
https://github.com/tensorflow/tensorboard/issues/61

How to find color of the objects(cloth color of human being)?

I had come across several stack overflow questions and solutions, in all the questions the solution is based on a particular color(red or green or blue). I need to identify the color of objects which are of multiple type. I need to detect color which ranged between 0 to 255. So can anybody help me with a solution based on opencv.
Thanks in advance.
If you already know about what could be the possible color then it very simple. I will talk about one example and you can follow the same procedure for rest.
Lets say that you have several possible combinations, for example a t-shirt could have red and cyan color and you already have an image of such a sample. Then you should do the following:
Step-1: Load the template/sample image. Calculate its Hue-histogram (or Hue-Saturation histogram).
Step-2: Load the image for which you want to know the color. Calculte the histogram for this image also.
Step-3: Perform histogram matching() between all the sample/template/example/possbile image's histogram (i.e. step-1) and the image for which you want to know the color (i.e. step-2).
Step-4: For which so ever combination, you get the maximum value...your image has that color. For example, lets say your sample images have an image of red & cyan t-shirt, another image of bule & purple t-shirt and so on. And you get the maximum histogram matching() value for blue& purple , it means that your image for which you want to know have blue and purple color.

Pointers on solving this Image Processing challenge?

The 2nd problem in IOI 2013 states:
You have an Art History exam approaching, but you have been paying
more attention to informatics at school than to your art classes! You
will need to write a program to take the exam for you.
The exam will consist of several paintings. Each painting is an example of one of
four distinctive styles, numbered 1, 2, 3 and 4. Style 1 contains
neoplastic modern art. Style 2 contains impressionist landscapes.
Style 3 contains expressionist action paintings. Style 4 contains
colour field paintings.
Your task is, given a digital image of a painting, to determine which style the painting belongs to.
The image will be given as an H×W grid of pixels. The rows of
the image are numbered 0, …, (H ­ 1) from top to bottom, and the
columns are numbered 0, …, W ­ 1 from left to right. The pixels are
described using two­dimensional arrays R , G and B , which give the
amount of red, green and blue respectively in each pixel of the image.
These amounts range from 0 (no red, green or blue) to 255 (the maximum
amount of red, green or blue).
Implementation
You should submit a file
that implements the function style(), as follows:
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]);
This function should determine the style of the image. Parameters are:
H: The number of rows of pixels in the image.
W: The number of columns of pixels in the image.
R: A two­dimensional array of size H×W , giving the amount of red in each pixel of the image.
G: A two­dimensional array of size H×W , giving the amount of green in each pixel of the image.
B: A two­dimensional array of size H×W , giving the amount of blue in each pixel of the image.
Example pictures are in the problem PDF
I do not want a readymade program. A hint or two to get me started would be nice, as I am clueless about this might be solved.
Since you are provided the image data in RGB format, first prepare a copy of the same image data in YUV. This is essential as some of the image features are easily identified patterns in the Luma(Y) and Chroma(U,V) maps.
Based on the samples provided, here are some of the salient features of each "style" of art :
Style1 - Neoplastic modern art
Zero graininess - Check for large areas with uniform Luma(Y)
Black pixels at edges of the areas(transition between different chroma).
Style2 - Impressionist landscapes
High graininess - Check for high entropy (salt-n-pepper-noise like) patterns in Luma(Y).
Pre-dominantly green - High values in green channel.
Greenavg >> Redavg
Greenavg >> Blueavg
Style3 - Expressionist action paintings
High graininess - Check for high entropy (salt-n-pepper-noise like) patterns in Luma(Y).
NOT green.
Style4 - Color field paintings
Zero graininess - Check for large areas with uniform Luma(Y)
NO black(or near black) pixels at the transition between different chroma.
As long as the input image belongs to one of these classes you should have no trouble in classification by running the image data through functions that are implemented to identify the above features.
Basically it boils down to the following code-flow :
Image has uniform luma?
(If Yes) Image has black pixels at chroma transitions?
(If Yes) Style1
(If No) Style4
(If No) Image is green-ish?
(If Yes) Style2
(If No) Style3
Maybe you can do a first approach using colors and shapes... In neo plastic modern it is likely that there will be only a few number of colors, occupying geometrical areas as in the colour field paintings.
This might gives you a way to differenciate styles 1 and 4 from styles 2 and 3.
In styles 1 and 4 you have large areas with the same color, but in style 4 the color is rarely a solid color but brush strokes of shades of the color.
Anyway you should look into the specialities of each styles, which are the usual colors and methods and then try to make your function "see" it.

Determine most visible foreground color [duplicate]

I'm drawing a color selection button and I'm looking for a nice and simple formula to get a good text color (foreground) for a given background color in RGB.
A simple try would be to just take the complement color but this will produce an odd looking button for colors like pure blue or pure red.
Is there something well known that does this?
If it matters at all, I'm using QT.
For maximum legibility, you want maximum brightness contrast without getting into hues which don't work together. The most consistent way to do this is to stick with black or white for the text color. You might be able to come up with more aesthetically pleasing schemes, but none of them will be more legible.
To pick between black or white, you need to know the brightness of the background. This gets a little more complicated, due to two factors:
The perceived brightness of the individual primaries red, green, and blue are not identical. The quickest advice I can give is to use the traditional formula to convert RGB to gray - R*0.299 + G*0.587 + B*0.114. There are lots of other formulas.
The gamma curve applied to displays makes the middle gray value higher than you'd expect. This is easily solved by using 186 as the middle value rather than 128. Anything less than 186 should use white text, anything greater than 186 should use black text.
I'm no expert on programming things related to RGB, but from a designer's perspective, often the most readable color will be just a much lighter (if the background color is dark) or darker (if the background color is light) version of the same shade.
Basically you'd take your RGB values and if they're closer to 0 (dark) you'd push them each up by an equal amount for your foreground color, or vice versa if it's a light BG.
Complement colors can actually be really painful on the eyes for readability.
Leverage an outline for legibility
If by "good text color (foreground)" you intend it for legibility purposes when the user chooses any background colour, you can always produce white text having a black outline. It will be legible on any solid, patterned or gradient background, from black through white and anything in between.
Even if this doesn't hit the mark of your intention, I think it worthwhile posted here because I came looking for similar solutions.
Building on top of Mark's response, here's some Ruby code that'll do the work
rgbval = "8A23C0".hex
r = rgbval >> 16
g = (rgbval & 65280) >> 8
b = rgbval & 255
brightness = r*0.299 + g*0.587 + b*0.114
return (brightness > 160) ? "#000" : "#fff"
You are better off with a high difference in luminosity. In general, colored backgrounds with colored text suck for readability, hurting the eyes over time. Lightly tinted colors (e.g. in HSB, S~10%, B>90%) with black text work fine, or lightly tinted text over a black background. I'd stay away from coloring both. Dark text (b~30%, s>50%) with a subtle coloration over a white background can also be fine. Yellow (amber) text on a deep blue background has excellent readability, as does amber or green on black. This is why old dumbterms (vt100, vt52, etc.) went for these colors.
If you really need to do color-on-color for the 'look', you could reverse both H and B, while pinning saturation at a moderate to low level.
And one last note: if you have a 50% gray background, rethink your interface. You're robbing yourself of half your dynamic range! You're alienating low-visibility users, including anyone over 35...
Color combinations often look terrible when not carefully chosen. Why not use either white or black for the text, depending on the Brightness of the color. (Will need to convert to HSB first.)
Or let the user choose either black or white text.
Or use pre-defined combinations. This is what Google does in their calendar product.
I've been looking for a simailr answer and came across this post and some others that I thought I'd share. According to http://juicystudio.com/services/luminositycontrastratio.php#specify the "Success Criterion 1.4.3 of WCAG 2.0 requires the visual presentation of text and images of text has a contrast ratio of at least 4.5:1" with some exceptions. That site lets you put in foreground and background colors to compute their contrast, although it would be helpful if it would suggest alternatives or ranges.
One of the best sites I've found for visualizing color contrast is http://colorizer.org/ It lets you adjust almost all manner of color scales (RGB, CMYK, etc.) at the same time and then shows you the result on the screen, such as white text on a yellow background.
I usually look at color complements, they also have color complement wheels to help
http://www.makart.com/resources/artclass/cwheel.html
If your color is HSL, flip the Hue by 180 degrees for a decent calculation
I wanted to put #MarkRansom's answer into use and managed to create this snippet:
I got the values From seeing how sRGB converts to CIE XYZ and built upon that.
The script simply tracks the position of the foreground item and it's position regarding the colored background items.
Then based on background luminosity it gradually changes the foreground text color to either black or white.
Open the codepen for full example
https://codepen.io/AndrewKnife/pen/XWBggQq
const calculateLight = (colorItem: number) => {
let c = colorItem / 255.0;
if (c <= 0.03928) {
c /= 12.92;
} else {
c = Math.pow((c + 0.055) / 1.055, 2.4);
}
return c;
};
const calculateLuminosity = (color: RGBColor) => {
return (
0.2126 * calculateLight(color.r) +
0.7152 * calculateLight(color.g) +
0.0722 * calculateLight(color.b)
);
};
const getContrastColor = (color: RGBColor) => {
if (calculateLuminosity(color) > LUMINOSITY_LIMIT) {
return FONT_COLOR_DARK;
}
return FONT_COLOR_LIGHT;
};
I thing that converting to HSV might be the way, but IMO changing hue would look weird. I'd try keeping the hue and fiddling with value and maybe saturation (light red buttons with dark red text ... hm sounds scary :-) ).

Opencart how to related 2 options in a product

Hello I have the following problem.
I have a product with two different options, size and color. But I didn't know how to related this options when someone is buying a product. For example.
I have 4 T-shirt on my inventory
2 Blue T-shirt size S
1 Green T-shirt size L
1 Yellow T-shirt size XL
I configured the product with these requirement options (size and color), but for example a customer can buy a T-shirt size XL color blue and that's wrong because I didn't have a way to related the color with the size. Any Idea, plugin or suggestion???
Thanks I'd appreciate your help.
take a look in the extension store for dependent options. that seems to be the thing you are after
There is an extension designed for this Related options for OpenCart