Group Abstract Group Abstract

Message Boards Message Boards

0
|
9.2K Views
|
7 Replies
|
9 Total Likes
View groups...
Share
Share this post:

Confused 'Old School' programmer (and Wolfram Programming Cloud)

Posted 12 years ago
POSTED BY: Jim MacAulay
7 Replies

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)

ClearAll@interface
interface[] :=
 DynamicModule[{url = "", y = Graphics[{}]},
  Grid[{{
     "Paste your URL below:"}, {
     Row[{Button["Click", y = getFacesFromUrl[url]], Spacer[10],
       InputField[Dynamic@url, String, ImageSize -> 750]}]},
    {
     Dynamic@y}
    },
   FrameStyle -> LightGray, Frame -> True, Alignment -> Left]]
POSTED BY: David Reiss

@David, some clue on this Dynamic bug? What I'm doing wrong?

POSTED BY: Rodrigo Murta

Code retyped...

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[]

Example of Face URL to past into InputField

Notebook Attached

Attachments:
POSTED BY: Rodrigo Murta

Rodrigo, nice job, any chance you will post code as code - not as image - or attach a notebook?

POSTED BY: Sam Carrettie

@David Yes!.. I know. I was still polishing it when it crashed.

Nice try with TextRecognize :)

POSTED BY: Rodrigo Murta

Just a quick comment: the Dynamic in front of the Column is probably not needed.

Alas, I tried to extract your code using TextRecognize on the image of your code, but only got gibberish...

POSTED BY: David Reiss

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.

enter image description here

enter image description here

POSTED BY: Rodrigo Murta
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard