# User talk:DrTrigonBot/JavaScript

## Initial and general talk

source Hello Rillke!

First thanks for all your support and hints in Commons:Bots/Requests/DrTrigonBot!! "Was lange währt..." usw. ;)

Now back to bussiness; to be honest I did not have time to introduce systematic label names and look into this - but that is what I will do next! ;) Did you have time to look into improving the javascript in order to support all templates including 'Position' data (Faces, People, ColorRegion, ...)? What about config options in order to choose what to show? Do you require me to fix the label names first? (despite the fact that it would be the proper order ;)

Some examples including 'People': File:APEX you at one of their Saturday cook outs.jpg, File:06award1.jpg

Thanks and greetings --DrTrigon (talk) 15:34, 6 July 2012 (UTC)

Hi, I hope you don't mind if I copy this to User talk:DrTrigonBot/JavaScript because I expect perhaps more conversation about this topic? Also this might be better for the future when people are looking for why the JavaScript works this way. If you don't like it there, just move. -- RE rillke questions? 15:40, 6 July 2012 (UTC)
No problem; feel free to move! (btw.: this is actually a brilliant idea! ;) We can still move it again later if needed...
Another (small) question; what about an illegal number of eyes, e.g. File:Azimov.jpg (I will implement a duplicate recognition later, but that since those hits are very rare, this is not my top priority... as mentioned before ;) Greetings --DrTrigon (talk) 15:45, 6 July 2012 (UTC)
Hello DrTrigon, at first thank you for the improvements to the color categorization. The pantone-colors are a good choice and are close to what the file shows. I will have a closer look at this and perhaps suggest the color categorization (and adding new color-categories to Commons at COM:VPP).
On File:Azimov.jpg there seem to be an issue with the calculation of which eye belongs to which face. At least 75% of the eye's area should be part of the face it is supposed to belong to, I think. And an eye should not take more than x% of the area (needs evaluation of faces).
Yes, I'll have a look how to implement a more generic JavaScript that allows highlighting of arbitrary any area and options. -- RE rillke questions? 15:48, 6 July 2012 (UTC)
Sounds good! I'm am intressed in setting up a color categorization. As I can see, this has to use another approach than the one currently existing since it is based on the color of the ROI (region of intresst) which is very hard (may be impossible) to find by bot. And the pantone set used consists of about 2000 colors - commons has in the order of about 10 color categories as the moment... ;)) Let me know when you need some support there...
Yeah... something similar is done already; the eyes are searched within the face area and close to it only. But the face regions detected do not include the same portion of the faces all the time; there are variations... and the same holds for the eyes... thus applying thresholds might not help that much, since it is what I am doing already... ;) ...but I will keep that in mind anyway! Greetings --DrTrigon (talk) 16:26, 6 July 2012 (UTC)
Again another question: Is there a way to switch on display for the template on a specific page? On User:DrTrigon/User:DrTrigonBot/logging this whould be very useful. Greetings --DrTrigon (talk) 16:38, 6 July 2012 (UTC)
Now some other news; I finally invested some time in solving TD-015, TD-016 and introduced label names (a long with docu, re-enabling some features you had already, ... ;) as mentioned some time ago. It would be very cool if you could adopt the javascript and double check the labels (if you have time). Then when everything works as it should we can speedy delete; {{FileContentsByBot/avgColor}}, {{FileContentsByBot/colorRegion}}, {{FileContentsByBot/eyes}}, {{FileContentsByBot/face}}, {{FileContentsByBot/facePosition}}. Btw.: Does it make sence to have an 'id' and 'class' in the same tag (like class="additionalInfoAvailable" id="bot-FileContentsByBot-Advertiser")??
And another thing I was confused about on File:Ban_Ki-moon,_Mrs_Ban,_Peter_Krämer_and_Jaka_Bizilj.TIF the javascript seemed not to work. Could you confirm this? Do you have an idea what's causing that effect? Thanks for your help and work! Greetings --DrTrigon (talk) 21:38, 7 July 2012 (UTC)
Just recognized (may be I should go to bed now... ;) that "bot-FileContentsByBot-..." (for 'id') should may be replaced by the simpler "FileContentsByBot-..."?! Greetings --DrTrigon (talk) 22:48, 7 July 2012 (UTC)
Finally I invested some time in refactoring the JavaScript to a more generic one. Do you think it's sufficient for your needs? On File:Ban Ki-moon, Mrs Ban, Peter Krämer and Jaka Bizilj.TIF, ImageAnnotator did not load. Regards -- Rillke(q?) 16:42, 14 July 2012 (UTC)
Nice, nice... very good work!!! Looks superb!! Thank you very much for your work and time! The check boxes to switch the boxes display on and off are very very cool! It has become a fairly mature user interface already... ;)) I am really happy with this!
I have some open questions and I hope you can answer them:
1. Is there a way to switch on display for the template on a specific page? I think of showing (display) the {{FileContentsByBot}} on User:DrTrigon/User:DrTrigonBot/logging this whould be very useful. On that page {{FileContentsByBot/generic}} is used only (at the moment) so no boxes to display in the image, but just remove: display:none.
2. Does it make sence to have an 'id' and 'class' in the same tag (like class="additionalInfoAvailable" id="bot-FileContentsByBot-Advertiser")?? Would it be ok to remove one? Or is the idea to have always a 'class' and 'id' addtionally if needed only, because then we have to add 'class' to all 'id', e.g. 'FileContentsByBot-DimX'...?
3. Would it be possible to have a pre-setting where you can define which check boxes are un/checked by default? Like the "display:none" thing...?
I will also fill the speedy delete requests in order to clean up the subpages and converge to a final and production ready template system. If there are other ideas or else, please do not hesitate to contact me! Thanks again for your work and greetings!! --DrTrigon (talk) 09:32, 15 July 2012 (UTC)
p.s.: ...and File:Boun 09-10.jpg (a nice example) including all methods - even though bots the detection was not perfect... ;) Have fun! --DrTrigon (talk) 09:34, 15 July 2012 (UTC)
Thank you.
1. Yes! Will look into this.
2. Yes! In the future we might have more of these texts (e.g. by different bots) so users who don't like seeing this can turn off all of them using just one line of CSS: (.additionalInfoAvailable { display:none; }); #FileContentsByBot-DimX is not visible - I don't see the need for a class here.
3. Yes! How it should look like? (Button to save current settings in a) a cookie (browser-dependent) b) DOM-storage (browser-dependent) c) user's common.js or skin.js (user-dependent)) An example of such a settings-wizard is in VisualFileChange.js/advanced configuration and /profiles
Yes, looks really good! -- Rillke(q?) 21:09, 15 July 2012 (UTC)
That are good news!
1. Cool, thanks!!
2. Ok... I see...! Regarding #FileContentsByBot-DimX I'm confused; there is no class at all, it is an id and additionally it is visible... (may be you mean "bot-Properties-Dimensions"?) Could you explain more in detail what you are thinking of here?
3. So... what do you prefer? What whould be of most use? If you insist in getting a statement from me; I would prefer something simple, thus I tend to c) but to be honest, I have no clue... ;))
Thanks and greetings --DrTrigon (talk) 21:51, 15 July 2012 (UTC)
2. I simply forgot that it is visible. Since there is only one of these fields per page, having an id is ok but if you prefer a class for consistency, I wouldn't oppose changing this into a class.
Regards -- Rillke(q?) 08:42, 16 July 2012 (UTC)
I think class is more consistent in that place... id's are used for simplicity in js (so you may / have to decide) and have to be unique (a small drawback from my point of view) ... ;) Greetings --DrTrigon (talk) 09:57, 16 July 2012 (UTC)
Feel free to switch to a class. I will adopt JS. Before the settings can be set, I have to write a settings-manager. This is long overdue now. -- Rillke(q?) 13:49, 20 July 2012 (UTC)
I will look into this once I have some time off to spend - currently I have to focus to some exams. But I like to thank you very much for the improvements you did meanwhile; saving configuration capability and Mouth/Nose positions! Thanks a lot!!!
For your information: I am now in the process of training some haarcascades in order to test this (this might take weeks for 1 of them). Once this works we can decide on what categories here in commons to train in order to enable detection of them (should be composed of "very similar looking" images only). A further step would be to finally define a set of features to use with more sophisticated and general classification algorithms (like SVM or else). I have to look into e.g. BagOf(Visual)Words and others too. There might be some things we can do for audio and video media - which sounds kind of cool - but since there are just few such files compared to images, this might be waste of time... ;) Some OCR should follow also, but can become very time consuming, e.g. on PDFs with hundreds of scanned text pages. Any other ideas and hints are very welcome. --DrTrigon (talk) 11:29, 12 August 2012 (UTC)
I'm back to this topic again... ;) ...so I try to reduce confusion regarding your last point 2.) from 16th of July; the initial reason why I raised this was the question "Does it make sence to have an 'id' and 'class' in the same tag (like class="additionalInfoAvailable" id="bot-FileContentsByBot-Advertiser")??" Which is still unclear to me... The question was not to change id to class but if it makes sence to have both (in the same tag)?
Another point I wanted to ask you for; 'OpticalCodes' do also have a 'Position' value, would it be possible to mark them in the image too (like for Faces, People, ...)? An example is File:Capa Farrazine 23.jpg.
Also 'Faces' do now have a 'Type' value that usally is '-' but can also be 'Exif' to mark face recognition done by e.g. camera software. You might want to distinguish those two types (in my oppinion this is not really needed or important).
Greetings --DrTrigon (talk) 12:45, 10 September 2012 (UTC)
additionalInfoAvailable could be used by different templates while bot-FileContentsByBot-Advertiser will be only used by your bot placing its template. So if someone does not want to see all these "infos", he can put .additionalInfoAvailable { display:none } in his css while bot-FileContentsByBot-Advertiser is accessed from the script that makes your bot's template visible (It should not change other template's additionalInfoAvailable if there would be more than one.) So it makes sense for me, yes.
I will provide an "API" for the script so you will be able to add new tags simply by editing a template.
Regards -- Rillke(q?) 15:10, 10 September 2012 (UTC)
Aaa, now I think I'm back to bussiness... (sorry for my confusion ;) That was the point! Thanks for making it concrete! And you mentioned "FileContentsByBot-DimX" later because there the id is not needed at all (no per user configurable view) and thus it should/could become a class for consistency? Is that correct?
Regarding the "API" you mentioned; sounds good - I am thinking about how to get those info automatically from other structure... All "Position" values should be displayed in general (so 'Faces' is a special case in the sense that there are 'Eyes', 'Mouth' and others too). May be that could simplify your approach?
Thanks again for your help and work!! Greetings --DrTrigon (talk) 17:19, 10 September 2012 (UTC)

## Script for scaling an image

source User talk:Rillke/Discuss/2012

I was able to solve it by writing my first javascript for wikipedia! ;) May be you could take a look at this too and give me some hints what I did wrong and how I could improve the code...? While doing this I came up with an old question: Why do we have to include the image width and height? In my script I was able to get those values in the code, all I had to do was include the image... Would this be a possible way to solve this in MediaWiki:FileContentsByBot.js too? I undid my changes since I was not shure on how stable the solution is, it needs additional javascript to see the icons and last bo not least they are very small and I am not sure if they are of any use at all, since you did such a great job...!? ;))) Greetings --DrTrigon (talk) 16:15, 15 July 2012 (UTC)

I thought you don't want to use JS? Of course it's possible using JavaScript without knowing the original height/width (they are still required for adding the annotations but could be retrieved from the API using JS, but this would be one request to the server more, so please keep FileContentsByBot-Dim[X|Y]) Here a few remarks about the code
// Use jQuery event-handlers!
// here: $(<your function>) (shorthand for$(document).ready(<your function>))
// e.g. $(function() { ... }) // Reason: Think about other scripts that would like to use the window's onload-event // - you would replace their handlers with your one // or think about running this script after the onload-event has fired -> no execution window.onload = function show_icons() { // No need for looking-up all divs (see below) var divs = document.getElementsByTagName('div'); var scale = 0.0; // default: image 0px thus invisible for (var i = 0; i < divs.length; i++) { // simply do it with jQuery-css-selectors: var$icons = $('div.bot-Faces-Position-icon'); // also, please always use strict comparison as it is easier to understand and allows higher performance in modern browsers // in JavaScript: null == undefined and 0 == "0" and some more oddities you should not attempt to make use of if (divs[i].className == 'bot-Faces-Position-icon') { // this is also easier with jQuery:$icons.show(); or $icons.css('display', 'inline-block'); divs[i].style.display = ''; // display icons //$icons.find('div a.image > img')
var subdiv = divs[i].getElementsByTagName('div')[0];
var img    = subdiv.getElementsByTagName('a')[0].getElementsByTagName('img')[0];
// having a ratio as a class is really "hackish" - there should be a better way (e.g. a hidden span with a verbose class attached that's content will be the ratio)
scale      = subdiv.getAttribute('class');

// re-scale image to new size (without having to specify the old pixel size)
img.width  = scale*img.width;
img.height = scale*img.height;
};
};
};


So writing this using jQuery would look like this:

$(function() {$('div.bot-Faces-Position-icon').each(function(i, el) {
var $el =$(el),                                   // turn DOM-node into jQuery-object (array-like-object)
$scaleDiv =$el.children('div:first'),         // find scale-div
$img =$scaleDiv.find('a.image > img'),        // find image
ratio = parseFloat($scaleDiv.attr('class'), 10); // Making explicit we want a float$img.width($img.width()*ratio);$img.height($img.height()*ratio); }).show(); // Finally show the image })  • jQuery has an awesome documentation: http://api.jquery.com/ • jQuery UI (needs to be loaded through RL but easy - if you find something you would like to see here: No problem. Finally, if you want to start with JS, read COM:User scripts: You need a js-debugger if you don't have one and a console so you don't have to use document.write (never use it!). Then you can simply write if (window.console &&$.isFunction(console.log)) window.console.log('your term', 'or multiple ones', ['in firebug you can log and inspect arrays', 'really!'], \$('#OrEvenDOMNodes')[0])

Regards -- Rillke(q?) 20:54, 15 July 2012 (UTC)

Yes I didn't want to use js in the first place and tried to avoid it if possible... ;) But you were right, it looks like this is the most straight forward way... So I took to oportunity to start learning it... :) Thank you very much for your exhaustive "beginners tutorial" I really appreciate this! Thanks for your improvements to the code, I added it to the docs. --DrTrigon (talk) 21:28, 15 July 2012 (UTC)
While reasoning about this, I have to admit my conclusion is that I did a design misstake in the very beginning of setting up the bot; I should have chosen a "relative" position output, a number $\in [0,1]$ realative to the images dimensions. This would remove the need for a js here at all (!) and would be at lot more useful also regarding any size of thumbnails of the image... But may be I will have a smart idea on how to migrate to this format someday...? ;) (with help of js it should be possible... :) --DrTrigon (talk) 22:06, 15 July 2012 (UTC)
Btw.: Did you have seen File:Boyband.gif? Would need something similar like available for pdf in order to be able to flip pages... ;) ...and a good way to store that much data... ;)) Greetings --DrTrigon (talk) 10:48, 16 July 2012 (UTC)
It looks like this script is not fully compatible with MediaWiki:FileContentsByBot.js because after I clicked on 'View them!' on most pages the faces vanish (but the space is still reserved, so it's not "display:none") and on some pages the faces are displayed but wrong region. Ideas? (btw.: the bot is running from TS and by cronjob starting from today! ;) Greetings --DrTrigon (talk) 17:34, 19 July 2012 (UTC)
The simple reason is that it is already in MediaWiki:FileContentsByBot.js (Show little face-icons) and runs twice for you, I guess. -- Rillke(q?) 18:09, 19 July 2012 (UTC)
A-ha! Indeed... ;) Thanks for that pretty simple solution!! Now the mean question; what if I would like to have the script running before MediaWiki:FileContentsByBot.js to see the faces already? I think it should simply check if MediaWiki:FileContentsByBot.js is running and if yes then skip. How to achive this here? Greetings --DrTrigon (talk) 19:52, 19 July 2012 (UTC)
Sorry, I should have mentioned that I built this in. Now, I included a "guard" against multiple "scalings" by simply looking whether it's visible. If your script should not run, if MediaWiki:FileContentsByBot.js does, you can use for example check this:
if ('MediaWiki:FileContentsByBot.js' === mw.util.getParamValue('withJS')) { /* ... */ }

-- Rillke(q?) 08:53, 20 July 2012 (UTC)
You see, I like "yoda-conditions" because I also write in Visual Basic (and C++) ;-) -- Rillke(q?) 08:53, 20 July 2012 (UTC)
Ok let's see, so if I understand this right this should prevent double scaling if I use this script withing my commons.js - and it works as I can see. Alternatively because of your change it should work with the old one anyway?! So when looking at e.g. File:Cati afis.jpg the first method works! The second not... (or am I doing something wrong? ;) Thanks and greetings! --DrTrigon (talk) 09:29, 20 July 2012 (UTC)
If your common.js runs after MediaWiki:FileContentsByBot.js, it does not work if you do not include one of the methods, that's right. As you may have noticed, mw.util.getParamValue('withJS') simply checks whether MediaWiki:FileContentsByBot.js is or will be loaded, the method, I used in this change, checks whether another script changed the visibility. One could also remove the class-attribute so other scripts won't find it. -- Rillke(q?) 12:24, 20 July 2012 (UTC)
So... because of random script loading order, both scripts need to check whether another one did a scaling already. I see... is a pitty but makes sense and is the most "secure" way to go... ;)
As I understand for User:DrTrigon/common.js I can simply copy'n'paste (re-use) the code from MediaWiki:FileContentsByBot.js you've written. But using the condition you mentioned here earlier in MediaWiki:FileContentsByBot.js would not work of course. (I see... ;) So I prefer to have just 1 version of code doing 1 thing (except to have a good reason to insist on the other solution)... just to keep things and docs simple. ;)
The term "yoda-conditions" was new to me... ;) Even I used to write in Visual Basic long time ago and still do so in C/C++ sometimes... ;)
Thanks and greetings --DrTrigon (talk) 13:21, 20 July 2012 (UTC)
I got a hint under m:de:Benutzer Diskussion:DrTrigon#DrTrigonBot that some images do have links onto themselves, like e.g. File:Beach Party.jpg. The questioner assumes that this might be related to the inclusion of Category:Exif to them (by Template:FileContentsByBot/Faces). I think, it might be related to the javascript code which actually uses all images again in order to display the faces. I do not know what's the cause - do you have a clue? Can you help? Thanks a lot and greetings --DrTrigon (talk) 10:04, 9 December 2012 (UTC)
Replied there as it was not really related to JS. I hope you don't mind. -- Rillke(q?) 21:20, 9 December 2012 (UTC)

## PDF content extraction

Another idea I came up with: What about extracting the PDF contents like text (and may be later images too) and store them here to some place (e.g. a sub-page ".../Contents/Text")? I think this is a good idea since this would allow the PDF contents to be searched also. The open question to me is where to store the data? Most of the time it is stored to the description page directly but this seems a bad concept for PDFs with 100+ pages. We could put it to a sub-page and then link that from template... So what do you think about that? Greetings --DrTrigon (talk) 10:37, 2 September 2012 (UTC)

My first thought is that the text should be stored in the PDF-File itself (I know that some OCR-programs add a text layer behind the image so one can select it) and MediaWiki's search engine should be able to extract the text from the PDF-file.
I also know that we currently store geo-data (kml-files) on sub pages. All in all, if you didn't invest a lot of time in OCR-handling of PDF-files, I tend to say, save your time: Common's project scope limits the number of allowed PDF-text files to a very low number and the PDF files that are used at WikiSource are treated with OCR an human reading there and can be indexed there.
OCR in general seems to be a good idea but I guess it takes a lot of processing power to search for text in each image. Perhaps OpenCV could detect whether the file is cartoon-like (or similar) and if so, your bot tries to extract text.
Thank you for your efforts, the kind message at my talk page and keep up good working. You may invite other people to share their opinion on OCR. Kind regards -- Rillke(q?) 20:29, 2 September 2012 (UTC)
Indeed, it would be more favorable if the wiki search would be able to crawl PDF and their content, but I doubt this works. At least I was not able to get any results (whether wiki search nor google). So shall I file a mediawiki feature request (or a bug) and wait for that functionallity? But if this functionally is not planned at all, what would you prefer? Keep it as it is now or implement something by ourselves? ;))
Regarding OCR and the time I've invested; Don't panic ;)) In fact I did not implement OCR yet, at the moment I am just extracting the (already existing) text layers from PDF. In future OCR funcionallity will follow (for pure images too). This OCR will most probably be based on Ocropy/w:en:Ocropus which is already a very mature and powerful library with python bindings. So I am free to spend my time elsewhere... ;))) Regarding processing power - the bot is currently restricted to process 250 pages a day only which is not necessary, but the bot uses a lot of ressources anyway (bandwidth, memory, ...) so you know... :))
So I would be happy to share oppinions about OCR (and other stuff ;) - what people are you thinking of? Greetings --DrTrigon (talk) 13:06, 3 September 2012 (UTC)
Btw.: When we do OCR on plain images e.g. we need again a place to store that content (keep in mind there are also multipage images, e.g. with scanned content)... ;) --DrTrigon (talk) 17:21, 3 September 2012 (UTC)
Concerning search indexing of PDF-content, I suggest you file a bug at bugzilla: that asks whether they intend to implement such a feature. If they won't implement it (or don't respond), it would be of course helpful. But I am not sure whether to use sub pages or pages with the same page name in a new namespace like for example done with the TimedText (srt files) for the subtitles of videos. This is something you should bring up to COM:VP and ask there or send a mail to the commons-mailinglist (I don't read this list ;-)) -- Rillke(q?) 19:50, 3 September 2012 (UTC)
Sooo... I looked it up and as you can see from bugzilla:6421 (and actually bugzilla:6422 too) they really intend to do so - already since 2006! So this might take some time again... (thus it might be worth considering this ;)))
Next step is to find the proper place to store such data (may be for other if not used here) and thus I did as you suggested and started Commons:Village pump#File content extraction and storage. May be you like to participate there too...? ;) If this does not lead to any useful insight then I will consider the maillist... :)
Thanks for your hints so far! Greetings --DrTrigon (talk) 15:55, 4 September 2012 (UTC)
It looks like the function will not be implemented in near future (< 5 years)... As mentioned on COM:VP the proper place for text storage might be wikisource... --DrTrigon (talk) 16:13, 8 September 2012 (UTC)

## Tri-Eyes

Another minor issue I came across today are 3 eyes detected in case the face was not properly detected, have a look at File:MARYJOSEFRANCO_LIZ_MEZA.jpg. So it's really hard to distinguish between correct and wrong ones since the face detection was not accurate. How to handle that? Enable at least 3 eyes to be processed and showed? Or just ignore them... At the moment the bot processes 3 eyes and writes them into the template as well, but the template and the js suppress the 3rd one. This is noting important - just wanted to read another opinion... ;) Thanks and greetings! --DrTrigon (talk) 14:24, 13 September 2012 (UTC)

If the bot would be otherwise very precise and produce no errors, this would be an issue but since there are more important issues, I don't have any strong opinion here. -- Rillke(q?) 16:44, 13 September 2012 (UTC)
I'll try to reduce all the other mess... ;) --DrTrigon (talk) 21:28, 13 September 2012 (UTC)

## API

Hello Rillke!

Regarding the 'OpticalCodes' and its 'Position' value mentioned earlier; you wanted to create an API in order to generalize (and simplify... ;) the process of "add new tags simply by editing a template". What about this? How is it going? Do you need help here?

Thanks and greetings --DrTrigon (talk) 09:22, 28 October 2012 (UTC)

Hi DrTrigon, I was terribly busy. Tomorrow, I'll have a look at it. -- Rillke(q?) 18:35, 30 October 2012 (UTC)
Sorry, time is running incredibly fast. Will try it this WE. -- Rillke(q?) 23:33, 31 October 2012 (UTC)
No problem as long as you will do it finally! ;) Let me now if I can do something for you! Thanks and greetings --DrTrigon (talk) 12:48, 7 November 2012 (UTC)
Now, 14 days later, a first interface is available. Have fun and tell me what else you would like to play with! -- Rillke(q?) 21:41, 13 November 2012 (UTC)
... ;) Don't panic! :) I looks very cool, as I have seen you already enabled the 'OpticalCodes' ... thanks a lot! I will give you feedback sooner or later! ;) Greetings --DrTrigon (talk) 02:26, 16 November 2012 (UTC)

## 3D drawing

Would it be a big deal to implement some 3D drawing in the java script in order to be able to display something like this or even more mature, like that ? But do not invest too much time into this, since this will mostly cover rare cases only. In fact a simple axis indicator showing the x, y, z directions, like on the left hand side of this example would be enough. We could place it in a corner of the picture. However the bot is with pyrev:11593 able to extract such data, with pyrev:11588 for chessboards also... ;)) Greetings --DrTrigon (talk) 18:26, 26 May 2013 (UTC)

WebGL looks promising (never used it but there is nothing that we can't achieve ;-) -- an easy solution which simply draws and transforms x,y and z axis should be possible with either SVG or canvas. Yes, SVGs can be dynamically created and manipulated and now almost all browsers support it. Canvas is more poplar, however (don't know why). I hope that I will find a simple solution/plugIn so I don't have to do all the calculations and drawing myself. All this will require quite a while.
Can you provide some estimated sample output by the bot? I guess it will be 3 angles (euler angles) or a rotation matrix? -- Rillke(q?) 21:28, 26 May 2013 (UTC)
Yes indeed... WebGL looks good! Cool! I did not knew about dynamically created SVG... go for it! ;) I do not know what format SVG "naturally" support, GL however is clearly fine. As you can see from my links the example there was also implemented using GL and is very straight forward, not much conversions needed. Do not hurry here, as I mentioned... this would be a "cool" feature but not very essential... ;))
An example for face is e.g. File:Brajesh Mishra.jpg, look for 'Pose' (not 'Nose' ;). The output is a rotation vector which is equivalent to rotation matrices. As you can see in w:en:Axis angle#Relationship to other representations the exponential map connects those two representations (essentially the lie algebra with the lie group). The explicit formula to come from one representation to the other is given by the w:en:Rodrigues' rotation formula#Conversion to rotation matrix, but may be the explanation in opencv docu is better.
If you need anything, please let me know...! ;)) Greetings and all the best! --DrTrigon (talk) 16:39, 30 May 2013 (UTC)
For the sake of completeness; for chessboards there is e.g. File:Board empty.gif as an example. Though I have to create the Template:FileContentsByBot/Chessboard first... ;)) Greetings --DrTrigon (talk) 12:23, 2 June 2013 (UTC)
Chessboard layer visualization could be done with plain CSS. See demo page (add rotate3d). For the WebGL-thingy, I'll have to import some libraries as well (a few years ago I made some tests with DirectX [and gave up because it was that complex; >50 lines of code for displaying a simple square; + a few lines for the usual windos executable stuff …]); OpenGL seems to suffer? from the same complexity. One has to compile and link Shaders! …. I am working but it can take some time. Is there a deadline (e.g. Wikimania) when it should be ready? -- Rillke(q?) 15:36, 26 June 2013 (UTC)
Indeed the CSS rotate 3D looks good, if you can use that to implement 3D axes (cross), rotate (and display) it that way we would take a giant leap forward. With WebGL you are mentioning the rendering of the 3D face model? IMHO this is not that important, even though it looks nice - but that also depends on your preferences! ;) I would suggest that may be we should first check what portion/ratio of images this applies to before you invest a huge amount of time.
There is no deadline! (Yet.) Honestly I did not think about such a thing or e.g. presenting that stuff at Wikimania - mostly because of a lack in time during my studies the last 5-6 years. But may be it would be worth considering it... Do you have experience in this? I was also thinking about writing a paper about pywikipedia - together with the rest of the community of course... What do you think about that?
Greetings and have a nice week! --DrTrigon (talk) 19:06, 7 July 2013 (UTC)

Hello Rillke! How are you doing? Hope you are fine! Any progress here meanwhile? As I can see, there are now numerous pages with with pose info, the last I've seen was File:Hugh Breeding in 1920's.jpg... Thanks for an update and greetings --DrTrigon (talk) 19:12, 21 February 2014 (UTC)

Hi DrTrigon, no progress, unfortunately. Probably in March, … as now POTY is running again. If you find another JS-coder, feel free to consult them. I won't sulk. Promise. -- Rillke(q?) 14:45, 22 February 2014 (UTC)
Do you know anybody (reliable)? Do we have a pool/portal here at wiki? But honestly I would prefer to stick with you... ;) Greetings --DrTrigon (talk) 19:06, 22 February 2014 (UTC)
Well, some people who want to see $$for their work. So I tried some examples, assuming a rotation vector // Euler vector but the output was trash. // X, Y, Z are values set by DrTrigonBot // Create a Vector (direction -> axis) var v = new THREE.Vector3( X, Y, Z ); // Obtain the vector's length, assuming it equals the rotation in radiants var vl = v.length(); var q = new THREE.Quaternion(); // If not normalized, tree.js does zooming and other undesired stuff q.setFromAxisAngle( v.normalize(), vl ); // So we have a rotation matrix now ... var m = new THREE.Matrix4().makeRotationFromQuaternion( q ); // simly load the wavefront obj var manager = new THREE.LoadingManager(); var loader = new THREE.OBJLoader( manager ); loader.load( 'face2.obj', function ( object ) { // Apply the rotation matrix to the face-object object.applyMatrix( m ); object.position.z = -1000; // scene was created earlier ... scene.add( object ); } ); So ... here is the output: File:Gracian 2012.jpg imgur; File:Grachev.JPG imgur; For rotation vector v=(π/4; 0; 0) pointing towards the +x-axis (which is to the right with the current camera view chosen): imgur, rotation by 45°; For rotation vector v=(0; π/2; 0) pointing towards the +y-axis (to top): imgur, rotation by 90°. Complete image set: [1] What's wrong with my code? As far as I can see it does what it is supposed to. -- Rillke(q?) 15:04, 5 March 2014 (UTC) BTW, where can I find the relevant source code of the bot? Seems to be deleted on fisheye und last commit to SVN.wikimedia was a few months ago. -- Rillke(q?) 15:04, 5 March 2014 (UTC) Wow now that's something I did not have expected!! Thanks for your effort! (Yeah the$$ guys I now too... ;))
First my source code, please confer wikitech:DrTrigonBot resp. pywikibot/compat from pywikibot/*. Due to svn2git and toolserver2labs migrations the source have been moved there. Look at e.g. line 788 and line 869.
Now regarding the actual issue: when looking at your code I think it looks reasonable, when looking at mine I can see that I calculate delta to neutral pose (which is defined as (π; 0; 0)) and there are some minuses as well, try e.g. -( (π; 0; 0) - v) and look what you get. I think I need to create a series of images of the axes according to given rotation vectors v used. In order we can compare our results/settings. I will do this as soon as possible... --DrTrigon (talk) 15:56, 9 March 2014 (UTC)
Here is a really great image for testing. Didn't have the time to go through your source code, though.-- Rillke(q?) 19:02, 9 March 2014 (UTC)