Image Properties is another feature provided by the Vision API. It provides us with properties like the amount of red, green, blue colors in an image, pixels, etc. The most important and useful of them being the detection of the dominant color component in a particular image.
This property would be implemented in a way so as to provide the end user, a functionality to get the content nodes grouped together under the link /node/{node_id}/relatedcontent. The grouping would be on the basis of similar dominant color component(Red, Green or Blue) in the images of the nodes.
Remaining Tasks:
Develop patch for the issue which fulfills the requirement.
(This is one of my tasks of the GSOC 2016 Project.)
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | Suggestions-implemented-2754391-8-16.patch | 7.36 KB | ajalan065 |
| #12 | interdiff-10-12.txt | 2.67 KB | ajalan065 |
| #12 | Comments-and-other-changes-done-2754391-8-12.patch | 20.91 KB | ajalan065 |
| #10 | interdiff-8-10.txt | 14.52 KB | ajalan065 |
| #10 | Tests-and-minor-changes-2754391-8-10.patch | 20.48 KB | ajalan065 |
Comments
Comment #2
ajalan065 commentedHere is the patch in progress.
At present, the patch creates a taxonomy vocabulary for the dominant colors and list the colors.
A controller is also added, which finds out the nodes which share the same dominant color.
A new page routed at /node/{nid}/relatedcontent would contain the links to these nodes.
Task Remaining:
The page needs to be built in the controller.
Comment #3
ajalan065 commentedHere is the patch which groups all the nodes which have same dominant colors in their images.
It creates a tab on the node/{nid} page under the name 'Similar Content' which displays the list of items sharing same dominant color.
Please review the work :)
Comment #4
ajalan065 commentedComment #5
ajalan065 commentedComment #6
eugene.ilyin commentedMhh, I think that if nodes have images with the same colors, then these nodes are not actually similar. I don't know how it can help to the end user.
In my opinion, more useful functionality is the search of the similar images by colors.
What do you think? Can you try to propose another useful cases?
We shouldn't just write the code, we should help to the end users.
Comment #7
ajalan065 commentedYou mean to say that instead of nodes, I should group the image files together?
Can you please elaborate your idea a bit on how to go about executing your idea? Sorry, but I could not extract much information from your suggestion above.
Comment #8
ajalan065 commentedHere is the patch which groups the related images together, instead of nodes, based on the similar dominant color.
Edit the settings for the image file entity, and select the Dominant Color vocabulary also, in addition to the dedicated vocabulary for the labels.
The value for "Store new labels in " should refer to the vocabulary of the labels, and not Dominant Color.
Each image file would have a tab named as "Similar Content" which displays the required result list.
Please review the patch :)
Comment #9
naveenvalechause this class above and then only use "Vocabulary::loadMultiple"
inject the connection object.
why double quotes and single quotes
use the Term class at the top and only use "Term::loadMultiple($tids)"
inject the connection object here.
Comment #10
ajalan065 commentedHere is the patch implementing the suggestions of #9. Also the patch contains tests for the issue.
Please review :)
Comment #11
naveenvalechause this class and only use "Vocabulary::create" method instead.
While you are on this file. Please either remove the @file doc or add the description about the file.
can we use the \Drupal::entityQuery here ?
declare $values as an empty [] before foreach. if none of the condition met then it will throw error.
Add a new line before doc comment.
Add the @param & @return types here.
Same as above. Add the @param and @return type here.
Comment #12
ajalan065 commentedHere is the patch following the suggestions in #11
Please review :)
Comment #14
eugene.ilyin commentedApplied with some corrections.
Be careful, better to try to load vocabulary directly $vocabulary = Vocabulary::load($vid); instead of loading all the vocabularies.
Multiple queries to DB in the cycle are awful. Never do it. Please correct to one query.
I believe that you can render the list not through prefix and suffix but through something like "item_list" please investigate this point.
db_query is deprecated. Don't use it.
I think that for route google_vision.related_content you should use permission 'administer files', because actually it's the list of the files and it's not related to administration of the google vision. I did it.
Comment #15
ajalan065 commentedSorry, I could not get which part are you referring to.
Please highlight the part which you refer, so that I may work on it.
Comment #16
ajalan065 commentedHere is the patch implementing the suggestions in #14.
1. db_query() is replaced.
2. prefix and suffix replaced by item_list
3. Multiple queries in the cycle of $build have been corrected to a single query.
Please review :)
Comment #17
naveenvalechalooks better
Thanks
Comment #18
naveenvalechaPatch committed and pushed to 8.x-1.x
Thanks!
Comment #20
eugene.ilyin commentedI think that the name of this feature is confusing. Dandelion and sand can have the same color. But hardly ever somebody will think that these images are similar.
Please improve instruction, info on the module page and text in interface to let the end user understand this feature better.
Comment #21
naveenvalechaFiled a followup for the same https://www.drupal.org/node/2783939