LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make a 2d array of an abstract shape drawing image

Solved!
Go to solution

I need to make 2 things :

 

1. Input a drawing with white background and black drawing (continuous line with random curves) and convert it to a 2d array

2. I draw on a paper above a camera and send live drawing

I'm quite new to labview, I know some machine vision feature but this is totally new for me

 

Thanks in advance, any help would be appreciated

0 Kudos
Message 1 of 20
(2,409 Views)

I hope you have a "reasonable" amount of experience and expertise in "ordinary" LabVIEW (i.e. LabVIEW + DAQmx, reading from USB DAQ devices and/or VISA so you have experience with getting data from Hardware and processing 1-D and 2-D Arrays of data), say several months.  LabVIEW "Vision" hardware works a little differently, and can be something of a challenge to tackle on your own.

 

I assume you have a WebCam or something similar that you plan to use to acquire your images -- something relatively inexpensive that is meant to be plugged into your PC's USB Port to allow you to make Video calls, for example (Logitech makes such things -- there's one sitting on my monitor).

 

Here's how to get started:

  1. Plug in your USB Camera.
  2. Open MAX.
  3. Look in Devices and Interfaces for your USB Camera.  It should have a Camera icon, the name of the Camera (e.g. HD Pro Webcam C920), and a IMAQdx name (e.g. "cam1").  Click to select the Camera.
  4. The right pane should now have two buttons, "Snap" and "Grab".
    1.   "Snap" will take a "snapshot".and give you a single Image.  Push the Snap button and see what happens.  Note that to see the entire Image in the MAX Viewer, you may have to right-click the Image and choose "Zoom to Fit".
    2. Look just under the Image at the various Settings.  You'll want to learn what these mean.  The number of Pixels (or "size") of the Image is set by "Video Mode".  You'll notice (probably) that the Image is in Color.  You'll need to use IMAQdx (I think) to get a Grayscale or Binary (which should be called "Black or White") Image.
    3. "Grab" produces a Video file.  You'll notice (in Video Mode) that there are a number of Video Formats you can use, Video Size, and (maximum) Frame Rate, largely set by your Camera's capability.
  5. Play around a bit to "get the idea".  Now you'll want to learn some IMAQdx, and how to work with LabVIEW Vision.  Unfortunately, this can be a little difficult to do "on your own", as there is not a lot of introductory material available.  There do appear to be some content on the Web (try "Learn LabVIEW Vision" or "LabVIEW Vision tutorial"), or do what I did, find someone who knows "the basics" (or maybe even is an expert in LabVIEW Vision), and learn together.

Bob Schor

0 Kudos
Message 2 of 20
(2,394 Views)

Oh about that I did have some experience, I make some pattern matching with 1 cam (both in labview and in vision assistant) , stereo calibration and depth image with 2 cam

0 Kudos
Message 3 of 20
(2,367 Views)

Should I put every 1(black) that appear on a 0(white) paper in an array?

0 Kudos
Message 4 of 20
(2,348 Views)

@PULSE.Wannabe wrote:

I1. Input a drawing with white background and black drawing (continuous line with random curves) and convert it to a 2d array

 


 

How should the 2D array represent the drawing? What's the datatype?

Is the drawing static?

 

An image is already basically a 2D array of pixels, so I am not entirely sure what you mean by "conversion"? What's the datatype of the desired 2D array (boolean? numeric? array of elapsed seconds since drawn? etc.) How will it be used later?

0 Kudos
Message 5 of 20
(2,328 Views)

I recommend that you go to the Web and type "LabVIEW IMAQ Image to array" and do some reading/studying.  Learn what a "Pixel" is, and how it can be represented.  Then think about what values you want for the Pixel.  Note Pixels come in various "sizes" (usually measured in "bits").

 

Bob Schor

0 Kudos
Message 6 of 20
(2,321 Views)

@PULSE.Wannabe wrote:

Should I put every 1(black) that appear on a 0(white) paper in an array?


Sorry I didn't make it clear here.

 

here's the step in detail : 

1. I draw an abstract line on a piece of white paper with black ink above a glass with camera below

2. The cam will capture an RGB image (I think)

3. I convert it to binary image then display it on a 2d array

 

but can I obtain which position / where did I start my drawing ? 

for example : I start drawing a straight line from bottom left paper, then I make a star shape, then from the last point, I make a zigzag line until it reach the end of the top right corner paper

 

0 Kudos
Message 7 of 20
(2,310 Views)

@PULSE.Wannabe wrote:
but can I obtain which position / where did I start my drawing ? 

for example : I start drawing a straight line from bottom left paper, then I make a star shape, then from the last point, I make a zigzag line until it reach the end of the top right corner paper

 


So you are still talking about a sequence of events (start...then...then...then etc.), so I am assuming that you want to modify the 2D array continuously while the drawing takes place.

 

If you get an RGB image, but you are dealing with a B&W image, it is sufficient to use one color channel (e.g. red). You you need a suitable calibration for the threshold to decide what's black and what's white.

 

2D arrays have index 0,0 in the upper left. If that differs for the raw image array, adjust accordingly. If the camera is below the glass, you might also need to mirror the image to represent how it looks from above.

 

Array elements on the front panel are typically significantly larger than a pixels, so most likely you need to do some decimation. Alternatively, you could display your array in an intensity graph, of course.

 

To give us a better idea what we are dealing with, could you attach a typical acquired image?

0 Kudos
Message 8 of 20
(2,296 Views)

example drawing

ex.png

example array of the drawing above

ex draw.png

I draw from bottom left to top right, I want an array that provides every pixel position from the bottom left to top right , first pixel position (x,y)  will be when I put my pen down (bottom right) and the last position is when I take my pen off the paper. but can labview do that? 

  

0 Kudos
Message 9 of 20
(2,276 Views)

The "short answer" is LabVIEW Vision can do that.  The more complete answer is that this is a multi-facetted problem, each part of which requires perhaps a reasonable level of expertise with both Image Acquisition and Image Analysis.

 

Here are some of the facets:

  1. You want to generate a path, or a time-varying location of a point.  This requires either a video recording or a timed series of static image acquistition, i.e. (to use IMAQdx terms), a "Grab" or a "Timed-sequence of Snaps".
  2. Depending on which option you chose, you will ultimately need to process a series of Images (either "frames of a Video" or multiple Image files recorded at known time points).
  3. The "single Image" question involves examining the Image and determining the "drawing point".  This is an "image-processing" problem, and (ideally) will let you assign a 2D coordinate to the drawing point.
  4. Now you have your 2-D "spatial coordinate" and (from the timing information on the Video or Static image file(s)) a third "time" coordinate to do with what you will, such as making a LabVIEW graph showing points being "drawn" as specified by your Image Analysis from the previous steps.

Bob Schor

0 Kudos
Message 10 of 20
(2,268 Views)