Just started looking at Wolfram Alpha so apologise in advance for my ignorance (I am familiary with traditional languages like C, JavaScript but also a bit of XSLT and Lisp).
Anyway, I thought I’d try to write a program that would allow a user to supply a URL of an image and then it would count the number of faces it found in the picture - thinking I should be able to do this in half a dozen lines of code.
Well, I fall at the first hurdle !!! I try using InputFileld to capture a URL from the user - the textbox appears fine but I can’t seem to access the value entered i.e. pictureurl = InputField[] just doesn’t set pictureurl !?!?!?
Any ideas what I’m doing wrong?
Also, on a seperate note - do I need to prefix every line with ‘CloundDeploy’ in order to ‘save it’ to the cloud - this seems crazy to me who is more used to the develop → compile → deploy way of coding.
Hi Jim.
I was working in a response for your, when my notebook crashed/froze.
Here is a print of the code, no time to retype now. It was working fine, but I lost the image url that I was testing.
ClearAll@getFacesFromUrl
getFacesFromUrl[url:Null|""]:=""
getFacesFromUrl[url_String]:=Module[{img,facesBox},
img=Quiet@Check[Import[url],Return@"Error loading URL"];
If[Head@img=!=Image,Return@"Not an Image URL"];
facesBox=FindFaces[img];
Rasterize@Show[img,Graphics[{EdgeForm[{Red,Thick}],Opacity[0],Rectangle@@@facesBox}],ImageSize-> 700]
]
(*THIS DYNAMIC PART CODE HAS SOME BUG IN MY MATHEMATICA 9
MY NOTEBOOK GET INTO A LOOP WHEN URL IS INSERTED AND ENTER IS PRESSED
THE MSG IS "FORMATTING DYNAMIC CONTENT"*)
ClearAll@interface
interface[]:=DynamicModule[{url=""},
Grid[{
{"Paste your URL below:"}
,{InputField[Dynamic@url,String,ImageSize->700]}
,{Dynamic@getFacesFromUrl[url]}
}
,FrameStyle->LightGray
,Frame->True
,Alignment->Left
]
]
interface[]
Give the following a try. The image is only updated when the button is clicked. Presumably the Dynamic is attempting to continuously update things even though there is no change in the input URL. The following works, mainly because the update of the image is user controlled–but of course it does not explain the problems you are having with the original code… I will think more to see if I can explain the issue (though it is likely covered in the documentation for advanced Dynamic)