The problem of IMAQ/Vision function?

I use ImageToArray function to extract a pixel array from an image. And I want to copy this array to the portion of the other image. I wrote a program as follow, but it dosen't work? Did anybody can help me.
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
Private Sub Test_Click()
Dim pixelArray1 As Variant
Dim testarray() As Variant
Dim filename As String
Dim image1 As New CWIMAQImage
Dim h As Integer,w As Integer
ChDrive App.Path
ChDir App.Path
filename = CurDir & "\\test.png"
CWIMAQViewer1.Palette = cwimaqPaletteBinary
CWIMAQVision1.ReadImage image1, filename
ReDim testarray(5000, 5000)
h=
image1.Height
w=image1.Width
pixelArray1 = image1.ImageToArray
CopyMemory testarray(1000,1000),pixelArray1,h*w*16
End Sub

Any time you use things like CopyMemory you need to be careful, and make sure you understand how things are really being stored in RAM. There are several things I would look at in your code.
First, the first argument of CopyMemory should be an address. It looks to me like you are giving the value stored in the 1000th row, and the 1000th column of testarray. If that element of the array actually contains an address then your in business, but more than likely it is undefined.
Second, arrays are stored in ram as one long continuous block of memory. The illusion of a 2D array is a higher level abstraction, done by the programming environment. The two arrays are stored as '1-D' continous blocks of memory. So, if your pixel array is 1000x1000, 5 rows of your so
urce will be stored in one row of your target. (5000/1000). The resulting image would definitely not be what you were expecting.

Similar Messages

  • Imaq vision function reference

    Hello All,
    I am new to Lab Windows/CVI and am using the imaq vision library.
    Could anyone tell me where I can find the IMAQ Vision function reference? I have found a function reference manual at Start--> National Instruments --> Vision--> Documentation. But, all the functions described in this document are starting with img******(). I was looking for functions beginning with imaq****().
    I am sorry as it might be a stupid question but any help would be appreciated.
    Cheers, 
    Solved!
    Go to Solution.

    Hello Harmonium,
    i think what you search is under Start --> National Instruments --> Vision --> Documentation --> NI-IMAQ IO
    In this directory you found the documentation for the imaq**** functions.
    C:\Programme\National Instruments\NI-IMAQ IO\Docs 
    There are three librarys the NI-IMAQ I/O, NI-IMAQ Librarys and the NI-IMAQdx. If you can please use the NI-IMAQdx library,
    because its the newest for doing aquisition. The documentation can be found here
    C:\Programme\National Instruments\NI-IMAQdx\Docs
    best regards
    Alexander Glasner
    AE NIE

  • IMAQ vision bug in several IMAQ vision functions

    Some IMAQ Vision functions malfunction if you use the source image as the mask. I keep running into this bug in IMAQ Vision, some Vision functions exhibit this behavior, and some don't. It is not documented in the function descriptions. Even if it were, it would still be a bug. Example:
    1. Create a U8 source image that contains some zeros and some nonzero values.
    2. Wire the image into the source input and mask input of IMAQ Quantify and return the % value of the global report to see what percentage of pixels are nonzero.
    The answer is wrong. If you copy the image into a separate image first, and wire the separate image into the mask input, you get the correct answer. See attached VI for edification
    Cheers,
    -root
    Message Edited by Root Canal on 04-20-2009 06:06 PM
    Message Edited by Root Canal on 04-20-2009 06:08 PM
    global variables make robots angry
    Attachments:
    mayor of bug town.vi ‏43 KB
    mayor of bug town.PNG ‏18 KB

    Identical thread in Machine Vision discussion forum: mask bug in several IMAQ vision functions
    Hope this helps.
    -Ben
    WaterlooLabs

  • Problems with IMAQ Vision after upgrading from Labview 6i to Labview 6.1

    Hi,
    We just upgraded from Labview 6i to 6.1.To do this,we uninstalled the 6i version as was suggested by NI and then installed the 6.1 version.Later when we tried to run the old vi's written using Imaq vision, we ran into different problems.Has anyone experienced any similar problems with IMaq vision after upgrading?If so please help me solve this issue.
    Thanx
    deepak

    What kind of problems?
    I would strongly suggest that you uninstall IMAQ (all elements) and reinstall them. They register with Windows, probably docked to 6i, and also must be recompiled, which I believe is done in installation.
    This is your best bet.
    If you still have problems, contact NI and ni.com/ask and start a support inquiry.

  • How to use the examples in IMAQ Vision Builder?

    I tried many times to use the examples brought in IMAQ Vision Builder(or LabView 6i ?) or download the similar examples from website of NI in order to learn some skills(I am really new with it!). But Whenever I click the example I want to run and a new dialog window always opened and ask me to find a VI named ???(??? is like for emample: IMAQ Windraw) and I always failed to find this VI!!! Where are this VI or How to use those emamples??? Thank you advanced!!!
    Swedlin
    [email protected]

    Hello Swedlin,
    IMAQ WindDraw is a VI that is included in the IMAQ Vision toolkit (see http://sine.ni.com/apps/we/nioc.vp?lang=US&pc=mn&cid=1305 for ordering information).
    If you are tring to run examples that include IMAQ WindDraw (or any other functions that are in IMAQ Vision), a dialog message will prompt you locate the VI manually (because the initial search failed).
    - Installing IMAQ Vision for LabVIEW will remove the message, and the examples will run.

  • What is the problem when your camera function doesn't work and lags?

    What's the problem when the camera function doesnt work and lags? Can my iPod touch be returned because of this? I have done nothing to damage the product.

    My file association for jpg files is correct, if i click on a
    jpg, ACDSee starts immediately.Although I am a long time Windoze non-user, I vaguely remember that there's a difference between correct file-type association being set and some application starting at a mouse click on a file icon. I also vaguely remember Windoze file-type association mechanism uses a few action-types. Java Desktop should expect a specific action-type for the association.

  • How do I fix the problems with text formating functions in hotmail and other text based sites?

    In a Mailing list provider site it disables the text formating functions, instead only showing a 'loading' message. The functions never appear. In Hotmail the scroll arrows on the right hand side does not work. Sometimes the email toolbar becomes 'grey' and the buttons do not work. When forwarding an email sometimes the email does not show in the new email message.
    == This happened ==
    Every time Firefox opened
    == Firefox was reinstalled March 2010.

    The only possible fix was turning the phone off immediately and burying it in a bag of dry rice for a week at least. That might...just might...have worked.  But you're way beyond that and I see no fixes.  In fact the phone is probably going to get more problems before finally gving up the ghost.  Continued use is just shorting out more and more of the circuitry.  For that reason I don't think repair is much of an option. Go to an Apple Store and buy an out-of-warranty replacement.

  • Can anyone help me out to find the diameter of the hole using imaq vision?

    have to measure the diameter of the holes and generate the report in the format given belowI have also enclosed the image to be processed)
    example:
    HOLE SPECIFICATIONS PLATE NO. 1
    X Y DIAMETER X Y
    C 8.4 3.79 3.122 8.472 3.675
    D 8.51 3.54 3.117 8.579 3.647
    F 0 0 1.089 0 0
    H 4.08 9.474 1.083 4.045 9.731
    J 3.78 9.86 0.845 3.698 9.957
    can anyone help me out to solve it,, Thanking you in advance!
    Attachments:
    03260005.JPG ‏103 KB

    Hello.
    I have some suggestions for the image processing component of your application. I have attached a Vision Assistant script to this post (Vision Assistant 7.1) which performs essentially the following steps. These steps could be followed in any programming environment and should yield decent results:
    Extract the Luminance plane from the RGB image (simply to get it into 8-bit mono format for the thresholding. Could be done with a color threshold VI).
    Threshold the image so that the bright components are left and the dark is set to 0.
    Perform a particle filter to remove the particles that are too large (the surrounding area).
    Perform a particle analysis on the remaining particles, which should be the holes in the
    plate only. Set the particle analysis to return the Location of the 'Center of Mass X' and 'Center of Mass Y,' and the perimeter (diameter).
    This type of processing would allow the plate to be rotated, have different patterns, etc. and you should still be able to get the information about the holes.
    Hope this helps.
    Regards,
    Colin C.
    Applications Engineering
    Colin Christofferson
    Community Web Marketing
    Blog
    Attachments:
    ExampleHoleScript.scr ‏2 KB

  • The IMAQ-Vision image display function seems to use two processors automatically

    Because the IMAQ-Vision function to display an image was slow for large images I wrote my own routine using the Windows SDK and it was much faster.
    However, now that the application has been moved to a dual processor PC the opposite is true, i.e. the application runs much faster if I use the IMAQ-Vision function. Inspection reveals that this is due to equal loading on the two processors, whereas if I use my SDK routine all the load is on the first processor.
    Is there some explanation for this? Do the IMAQ-Vision routines have built in multi-threading?

    Sir,
    Naturally, the IMAQ Vision display function does use multi-threading. Whether it uses the second CPU for this thread is operating system dependant.

  • How do I convert an IMAQ image buffer into an IMAQ Vision 'Image'?

    Using NI IMAQ and IMAQ Vision with LabWindows/CVI 6.0...
    I have some acquisition code that uses IMAQ img functions to set up a
    triggered image acquisition and stores the image into an 1D unsigned char
    array buffer.
    I would now like to add code that uses the IMAQ Vision functions. The IMAQ
    Vision function use an Image data type, which from what I can glean from the
    ..h files, is a structure.
    Is it possible to convert the 1D unsigned char array image buffer to an
    Image? How would I do this?
    An inefficiant brute-force way would be to write the image to a BMP file
    from IMAQ using imgSessionSaveBufferEx, then read the same file back in
    using IMAQ Vision imaqReadVisionFile. I am hoping there is a more elegant
    way to perform the conversion in memory without needing to write disk files.
    Thank you,
    Robert Rafuse
    Etec, Inc.
    tel: (978)531-5025
    e-mail: [email protected]
    web: http://www.etec-inc.com

    Bob Rafuse wrote:
    > Is it possible to convert the 1D unsigned char array image buffer to
    > an Image? How would I do this?
    Never mind. I found:
    http://sine.ni.com/apps/we/niepd_web_display.DISPLAY_EPD4?p_guid=B45EACE3F11556A4E034080020E74861&p_node=DZ52490&p_submitted=N&p_rank=&p_answer=&p_source=External
    which indicates that the img functions actually return a 2D array, so I can
    use imaqArraytoImage after all.
    My bad.
    Bob

  • Multi-camera acq w/IMAQ-Vision processing; how to translate buffers?

    I have a multi-camera system using genlocked cameras and a PCI-1408. I'm developing my application using LabWindows/CVI. I can acquire from each camera in turn using NI-IMAQ low-level functions (ref.: scan 1408 channels.c), but I want to process the images using high-level IMAQ-Vision functions. How do I translate an image captured into a low-level buffer (imgCreateBuffer) into an Image buffer (imaqCreateImage)? Are the buffer structures from imgCreateBuffer the same as imaqCreateImage, so that I can simply cast the void* returned from imgCreateBuffer to an Image* parameter in an imaq_xxx function? If not, how do I move an image from one buffer type to the other?
    Thanks!
    Jesse

    Well, I'm answering my own question!
    Turns out that the image buffer from imgCreateBuffer is an integer array. To get this into an Image structure from imaqCreateImage, use imaqArrayToImage.
    Hope this helps the next person.
    Jesse

  • Two problems with Zen Vision: M

    Hi all. I'll give my player's specs before describing the problem(s):Zen Vision: M 30 GBVersion .40.02 Anyway, I've had my Zen for about 4 months now, and up until now, it's worked perfectly. Recently, for the first time, it froze on me. I figure it was because I was shuffling through songs on random too quickly, as I see other people have had this problem too. So I reset the player, but it only rebuilt halfway; on the "Rebuilding" screen, the green line stops about halfway through. Now, whereas I once had about 2600 songs I'm down to a little over 000. I didn't think it was that big of a problem; I've either got all my songs backed up on my computer or CD. But when I connected the Zen to my computer, my computer couldn't read the device. Sort of, that is. My Zen can still charge through my computer and when I plug it into the computer, a message will pop up asking me what I'd like to do with the MP3 device. However, when I go to Zen Vision: M Series Media Explorer, I get the message "Your player is not connected. Please connect your Zen Vision: M Series to the computer." I went through the FAQ at the top of the message board and tried basically every solution outside of trying the Zen on another computer. I'm thinking it's a problem with the player, not my computer. It still acts erratically at times- like, if I leave it off for an extended amount of time and turn it on, it'll go into rebuilding mode. Other than that, though, it's fine. Could the hard dri've be corrupted Any help would be appreciated.

    I have the same problem. It all started yesterday when I was installing the cd drivers in my new computer. I have searched numerous forums and some people had to return the product. Please admins help on this issue as I understand it is very serious.

  • Problem using the IMAQ Extract function.Not getting two different image out

    Hi, I am trying to use the multiple IMAQ extract functions to get certain parts of the webcam image and then using the color extract function to get the average RGB values. The problem is that both the IMAQ extract functions give the same image on its output port. The block diagram snippet and VI are attached below. Also, please let me know if there is a better way of doing this. I need to expand this later to extract rgb values of about 40-50 different parts of the image instead of just two shown below.
    Solved!
    Go to Solution.
    Attachments:
    Extract RGB Data.vi ‏104 KB

    You did not create another image that you should wire to the input "Image Dst" of "IMAQ Extract".  That's why you always operate on the original image (which you should not do if you intend to operate on several regions of the image).
    Solution: 
    (1) Create a new image and wire this to "Image Dst".
    (2) Apply the histogram operation sequentially (e.g. in a loop).
    That way you will notice, that Image Dst contains actually(!) the region you have specified.  (Put a probe on the image wire that goes from the Extract VI to the Histogram VI).

  • Could I use the square grid for calibration in IMAQ vision?

    In IMAQ vision 6.0, NI provide the circular grid for system calibration.But now for some reasons,we need to use the square grid for calibration.Could the square grid be used with the calibration functions in the IMAQ vision for system calibration? What special things do we need to consider when we use the square grid for calibration?

    Are you talking about the layout of the points that make up the grid, or the shape of the points, or something else?
    Using dots in a rectangular grid with regular X and Y spacing is the standard grid for the NI calibration routines.
    I don't think the shape of the dots is critical. They could be small squares instead of circles.
    If you are talking about making a grid using lines instead of dots, like a tic-tac-toe board, I think you will have problems with the NI routines. You could probably do some processing on the grid image to reduce it to dots at the intersections, but it doesn't seem like it would be worth the effort. I would just use a grid made of dots instead.
    If this doesn't help, explain your problem more clearly.
    Bruce
    Bruce Ammons
    Ammons Engineering

  • Writing a Compressed AVI File in NI LabWindows/CVI with the IMAQ Vision Acquisition

    I'm still facing some problems when I try to save pictures from a GigE Vision camera into a compressed avi-file in a LabWindows/CVI application on Windows7.
    The task is to grab images from the camera with 30 fps to monitor a process, evaluate the grabbed pictures to find certain characteristics of the monitored process and save them in an avi-file to have the possibility to load and evaluate them once again Offline if necessary.
    My questions: which compression filters can I get with the NI-Imaq Vision Acquisition and Vision Development Runtime 2012 SP1? Is a mpeg4 codec available to compress quickly and effective? Can I use a third party codec or only the ones delivered with NI-Vision?
    I posted the problem two times already, but there is little response up to now. Thanks

    The encoding algorithm, or codec, that's used for compression needs to present on your system. When I had done some research on this sometime back, I found that if your custom codec could align with the DirectShow architecture, then your codec would work with IMAQ AVI functions.The codecs that are available may vary from system to system, depending on what software is currently installed. Be sure to check out this article:
    Writing a Compressed AVI File with the IMAQ Vision Acquisition Software
    Adnan Zafar
    Certified LabVIEW Architect
    Coleman Technologies

Maybe you are looking for