Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving an imaq image to disk using CWIMAQVision

Hey timmkish,

 

You should just need the Vision Acquisition Software to save an image. You're just using the functionality of the IMAQ API, which is supported by Vision Acquisition. VDM is just mainly for image inspections and processing.

 

I would check your NI licnese manager to make sure that everything you need is activated/installed. You can find that in Start>>All Programs>>National Instruments>>NI License Manager.

Message Edited by Chris_VH on 11-17-2008 02:03 PM
Chris Van Horn
Applications Engineer
0 Kudos
Message 11 of 56
(6,010 Views)

OK, I was just told the complete opposite by your tech support over the phone.

 

Can you please verify?  The VDM is $3600....

0 Kudos
Message 12 of 56
(6,006 Views)

License Manager says

Vision Acquisition Software v8.6

Status: Activated for this computer.

 

Inludes the following features:

 NI-IMAQ

NI-IMAQdx

NI-IMAQ I/O

0 Kudos
Message 13 of 56
(6,004 Views)
May I ask who you talked to, or if a service request number was generated. I'm very curious as to what you are doing that they believe needs VDM. Let me look into the documentation a little bit more to see if something that you are trying is unsupported without VDM, but I believe you can do everything with just the IMAQ drivers (including IMAQdx which needs a license)
Chris Van Horn
Applications Engineer
0 Kudos
Message 14 of 56
(6,003 Views)

Sorry, I closed out the tab that had the service # on it.

 

Here's what I'm doing:

1) I take the 'low level snap' example code I found in 

F:\Documents and Settings\All Users\Documents\National Instruments\NI-IMAQdx\Examples\MSVB.NET\Low-Level Snap

2) Opened the VB project file, compiled and ran it fine (it runs more like a low level grab, but whatever)

3) So the example code works fine.

4) In the Form designer, I add the CWIMAQvision control to the form

5) Change the name from 'AxCWIMAQVision1' to 'CWIMAQVision1'

6) Add 

CWIMAQVision1.WritePNGFile(myImage, "F:\myimage.png")

 

right after the section of code that says

' Get and display the image
        status = CWIMAQdx.GetImage(session, myImage, CWIMAQdx.BufferNumberMode.BufferNumber, 0, BufferNumber)
        If (status <> CWIMAQdx.Error.Success) Then
            GoTo ErrorHandler
        End If

7) Compile and run the program again.  When I click the 'Start' button, I get an error message on the line of code:

CWIMAQViewer1.Attach(myImage)

 

And the error message says 'Unlicensed copy of NI Vision'

0 Kudos
Message 15 of 56
(6,001 Views)

I just looked into the documentation a little more, and unfortunately, it looks like the CWIMAQVision call is actually in the VDM. So, I'm assuming this worked for you once, meaning you had the evaluation copy, correct?

 

It looks like the only other method would be the SaveImageToDisk method, which does not use VDM calls. I will paste the readme for that function call, and you can look over and try it.

 

SaveImageToDisk Method
Syntax
CWIMAQ.SaveImageToDisk Filename, SourceImage

Return Type
Long

This method returns 0 on success, a negative number on an error, and a positive number on a warning.

Purpose
Saves an image to disk. This method saves border and padding information with the image data. To write an image to file without the border and padding information use the WriteImage method.

Remarks
Call this method to save an image to disk in a native operating system-specific format, such as bitmap (BMP) or tagged image file format (TIFF). The image must be the same size and have the same bits per pixel as images in the image collection of the CWIMAQ control. Save 10-bit, 12-bit, 14-bit, or 16-bit monochrome images as portable network graphics (PNG) files.

Parameters
Filename As String

The filename of the image to save to disk.

SourceImage As CWIMAQImage

The image to save to disk.

Example
Private Sub Run_Click()
    CWIMAQ1.AcquisitionType = cwimaqAcquisitionOneShot
    CWIMAQ1.AcquireImage
    CWIMAQ1.SaveImageToDisk "c:\images\image1.bmp", CWIMAQ1.Images(1)
End Sub
 

Chris Van Horn
Applications Engineer
0 Kudos
Message 16 of 56
(5,997 Views)

When I add the 'CWIMAQ' object onto my form, add the lines of code that you specified, run the program, I get:

 

COM exception was unhandled

Saving IMAQ operation No interface found

0 Kudos
Message 17 of 56
(5,991 Views)
I believe that you do not need to add another CWIMAQ, but merely use the same one that you used for the acquire and display.
Chris Van Horn
Applications Engineer
0 Kudos
Message 18 of 56
(5,988 Views)
I didn't add another CWIMAQ, that is the only one
0 Kudos
Message 19 of 56
(5,983 Views)

Imports NationalInstruments.CWIMAQControls
Public Class Form1
    Dim error_code As CWIMAQdx.Error
    Dim SID As CWIMAQdx.Session
    Dim myimage As New NationalInstruments.CWIMAQControls.CWIMAQImage

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        error_code = CWIMAQdx.OpenCamera(CameraName.Text, CWIMAQdx.CameraControlMode.Controller, SID)

        error_code = CWIMAQdx.Snap(SID, myimage)

        error_code = CWIMAQ1.SaveImageToDisk("f:\myimage.tif", myimage)

    End Sub
End Class

 

This is the code I have that doesn't work

0 Kudos
Message 20 of 56
(5,979 Views)