How to draw rectangle over image viewer?

Hi, I want to draw rectangle over image viewer Control in the milestone client while displaying live video.

Take a look at the SmartClient plugin example called VideoAnayltics

It has sample code that draws text and rectangles as an overlay on the ImageViewer control.

I have a WinForms application (that was based on the VideoViewer sample) which also is uses ImageViewer control and adds overlay text and rectanbles.

With the ImageView Control I register for the ImageDisplayedEventan

In the event handler I build a list of Shapes

List<System.Windows.Shapes.Shape> shapes = new List<System.Windows.Shapes.Shape>();

Then I add the list to the ImageViewer

imageViewerControl1.ShapesOverlayAdd(shapes, overlayParams);

When you need a new list of shapes, you can remove the old list.

Hi, @Roger Hardiman@Bo Ellegård Andersen (Milestone Systems)​ .

I’ve put my plug-in in the milestone client. the plugin has an image viewer control.

i wish to implement a flow like this:

  1. User uses mouse to drag a shape (rectangle or polygon) (it’s the Region of interest)
  2. the shape is being drawn on the image viewer video as the drag continues
  3. user finish the drag → the shape stays on the image viewer control

Can you suggest the best practice for this?

thank you.

I have done something similar in a stand alone application using ImageView Control. I assume it will work inside SmartClient.

With ImageViewControl you can register for Click Events and Mouse Move Events.

I use the Click Event to store the Mouse.X and Mouse.Y position and the Mouse Move Event to draw a rectangle using the ‘Shape Overlays’. (I update ShapeOverlay on every mouse move)

You will have to do some maths on the X and Y positions.

I found the The X and Y positions relate to the whole ‘ImageViewControl’ area so you need do to some maths to convert these into the position in the camera image.