Message Boards Message Boards

Create a Custom User Interface for my Program

Posted 11 years ago

I have created a small program which takes an image from the webcam and plots the imagedata into a listplot. I want to create a GUI so that when I click a button the webcam should turn on and capture the current image and output the plot. I don't know how to create a function to this and also a user interface. Can you please help me. The notebook file is attached.

Thank you

Attachments:

Something along the lines of the following may be a start...

Framed@DynamicModule[{a = "", b,(*c,*)d, e, f, g, t, red, green, blue,
    rgb, max, mean, total, graph = ""},


  Column[{
    Button["Take Image",
     (a = ImageResize[CurrentImage[], 400];

      b = ImageData[a][[115, 1 ;; 320]];
      c = b[[All, 1]];
      d = b[[All, 2]];
      e = b[[All, 3]];
      f = Table[Max[b[[i]]], {i, 1, Length[b]}];
      g = Table[Mean[b[[j]]], {j, 1, Length[b]}];
      t = Table[Total[b[[j]]], {j, 1, Length[b]}];

      red = 
       ListLinePlot[c, AxesOrigin -> {0, 0}, DataRange -> All, 
        AspectRatio -> 1/10, Mesh -> All, PlotLabel -> "RED", 
        ImageSize -> 400];
      green = 
       ListLinePlot[d, DataRange -> All, AxesOrigin -> {0, 0}, 
        GridLines -> Automatic, AspectRatio -> 1/10, 
        PlotLabel -> "GREEN", ImageSize -> 400];
      blue = 
       ListLinePlot[e, DataRange -> All, AxesOrigin -> {0, 0}, 
        GridLines -> Automatic, AspectRatio -> 1/10, 
        PlotLabel -> "BLUE", ImageSize -> 400];
      rgb = 
       ListLinePlot[{c, d, e}, DataRange -> All, AxesOrigin -> {0, 0},
         GridLines -> Automatic, AspectRatio -> 1/10, 
        PlotLabel -> "RGB", ImageSize -> 400];
      max = 
       ListLinePlot[f, DataRange -> All, AxesOrigin -> {0, 0}, 
        GridLines -> Automatic, AspectRatio -> 1/10, 
        PlotLabel -> "MAX", ImageSize -> 400];
      mean = 
       ListLinePlot[g, DataRange -> All, AxesOrigin -> {0, 0}, 
        GridLines -> Automatic, AspectRatio -> 1/5, 
        PlotLabel -> "MEAN", ImageSize -> 400];
      total = 
       ListLinePlot[t, DataRange -> All, AxesOrigin -> {0, 0}, 
        GridLines -> Automatic, AspectRatio -> 1/10, 
        PlotLabel -> "TOTAL", ImageSize -> 400];
      graph = ""
      ), ImageSize -> 140],
    ButtonBar[{
      "RED" :> If[a === "", Null, graph = red],
      "GREEN" :> If[a === "", Null, (graph = green)],
      "BLUE" :> If[a === "", Null, (graph = blue)],
      "MAX" :> If[a === "", Null, (graph = max)],
      "MEAN" :> If[a === "", Null, (graph = mean)],
      "TOTAL" :> If[a === "", Null, (graph = total)]}],
    Dynamic@
     Grid[{{a}, {If[graph === "", "", graph]}}, 
      ItemSize -> {{1, 1} -> 500, {2, 1} -> 500}]
    }]
  ]
POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract