Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

For Loop? 1

Status
Not open for further replies.

snt

MIS
Jun 19, 2000
104
US
I have a function call 'Call frmMain.DTAFGMON1.Aqcuiremem(0,1,Singleshot).'
Basically this is a control to get a single frame from a frame grabber. The 0 is which window to display, and the 1 is how many frames to acquire.

I need to have this loop. I need to tell it to send frame1 to windwow1, frame2 to window2, frame3 to window3, and frame4 to window4. I then need it to go and start at 1 again in a loop until it is stopped, probably by a button.

I do not know much about programming, so any help is greatly appreciated.

BTW, I do not have the source for the control, and I can not get it.

-SNT
 
Frame 2 would be the second time around. I can tell it just to take x number of frames, but it seems to me that it would be easier to loop though taking one frame at a time.

-SNT
 
I don't really know exactly what you need to do without having the control you are using but the basics of what you are trying to do would be something like this:

Add the control and two buttons called say cmdStart and cmdStop to a form.

Then add

Dim bolCancel As Boolean

To the forms declarations

and the following two modules to the code

Private Sub cmdStart_Click()
Dim I as Integer

bolCancel = False
I = 1

While Not bolCancel
Call DTAFGMON1.Aqcuiremem(I,I,Singleshot)
DoEvents
I = I + 1
If I = 5 Then I = 1
Wend

End Sub

Private Sub cmdStop_Click()
bolCancel = True
End Sub


Or something along those lines.
 
Ok, how do I send 2 to window 2 and 3 to window 3, etc...
 
One last thing, hopefully.

If i = 2, how do I dispay it in a picture box on form 2?

-SNT
 
This is where we can't really help without knowing how that control works.

Maybe if you just post the first four calls to it the way they would work if you just coded them in a sequence?
 
This seems to be defined in the control. I don't have the source for it.
---
The source from the example:
frmMain.Picture1.Visible = False
frmMain.DTAFGMON1.Visible = True

Call frmMain.DATFGMON1.AcquireMem(0, 1, SingleShot)
---

That's pretty much it.
 
Well you wouldn't normally have the source for a third party control but if you also have no documentation I don't see how you can use it (short of examining each method to see what parameters it takes and making inferences from that).

The above tells you pretty much nothing.

Where did you get it? Is there more explanation where you got the above code?
 
This is the entire page:
Code:
Syntax:	Call object.AcquireMem(Window As Long, BufferCount As Long, Mode As AcquireModeEnum) 

Description

Acquires one or more ROIs to memory buffers, displaying the data in a window, if desired. 

Parts of Syntax

Name	object
Type	DTAFGMON
Description	The name you assigned to the control.
Range	N/A

Name	Window 
Type	Long 
Description	The handle of the window in which you want to display the acquired data. 
Range	Any valid window handle. If you specify a value of 0, data is displayed on the surface of the control. If you specify a value of –1, no data is displayed. 

Name	BufferCount
Type	Long 
Description	The number of buffers that you want to use for the acquisition. Each buffer is equal to the size of the current region of interest (as defined by the ROIWidth property and the ROI Height property). 
Range	Depends on the size of the current ROI and the amount of available system memory. 

Name	Mode 
Type	AcquireModeEnum 
Description	The acquisition mode. 
Range	SinglePassSync = As you acquire frames/fields, save ROIs to the number of buffers specified by BufferCount, then stop the operation. This method operates synchronously when SinglePassSync mode is used. 
	SinglePassAsync - As you acquire frames/fields, save ROIs to the number of buffers specified by BufferCount, then stop the operation. You can also use the StopAcquire method to stop the operation, if required. This method operates asynchronously when SinglePassAsync mode is used. 

Note that typically you will not use this mode. It is useful if you expect your acquisition to take a long time and want to process data while the operation is in progress, if you are using an external trigger, or if you are using a variable-scan signal. 

ContinuousAsync = As you acquire frames/fields, save ROIs continuously to the number of buffers specified by BufferCount until the StopAcquire method is called. When BufferCount buffers are filled, overwrite the first buffer. This method operates asynchronously when ContinuousAsync mode is used. 

Returned Value

None

Remarks

The size of each buffer is based on the ROI size. If you are acquiring frames, one frame is stored in each buffer; if you are acquiring fields, one field is stored in each buffer. 
When you call the AcquireMem method, the software allocates BufferCount memory buffers. To access these buffers, use the GetBuffer method before you call AcquireMem again. 
For more information about performing single-pass or continuous acquisitions, refer to the example programs on the Imaging OMNI CD. 

Example

'acquire 10 ROIs to memory and stop;
'do not display the ROIs

Call DTAFGMON1.AcquireMem(-1, 10, SingleShot)

Hope this is of some use.

-SNT
 
Well what you are attempting is what would be called non-trivial.

I don't think I will be able to give you the answers you are looking for without having the control myself.

But I'll try to help.

First of all I would play around with this by calling it with 0 as the first parameter and a higher number for the second and I think SinglePassSync (not sure how or if the constants for that parameter are defined.) That seems like it will cause it to display a sequence of frames on the control itself.

Do you have that much or even a single frame being displayed already working?

Then it looks like your next step is going to be to call that with -1 as first parameter (so it doesn't display at all) and the number of frames you want as the second.

Then use a loop with one or more of the controls other methods to display the captured buffers in seperate windows.

I don't know which methods those are but they mention a GetBuffer in what you posted. It will be something like that (maybe even that). Some method or methods that they provide that let you get and display the buffers that the AquireMem method has captured.

Make any sense so far?

After that you may be able to display the captured buffers
on forms you create by using the forms hWnd property but I really don't know about that and that is getting a bit ahead of where you are now.




 

Try this (freely stealing from the code supplied earlier):

Add a form to your project and call it
frmDisplay.(You may need to set autoredraw to true)

Add this code to your startup form (assuming form1)

Dim theWindows(4) as frmDisplay
'frmDisplay is just a basic form
'from which we will get the hWnd

Dim bolCancel As Boolean



and the following modules to the code

private Form1_load()
dim x as integer
for x = 1 to 4
set TheWindows(x) = new frmDisplay
theWindows(x).show
next
end sub


Private Sub cmdStart_Click()
Dim I as Integer

bolCancel = False
I = 1

While Not bolCancel
Call DTAFGMON1.Aqcuiremem(theWindows(x).hWnd,1,Singleshot)
DoEvents
I = I + 1
If I = 5 Then I = 1
Wend

End Sub

Private Sub cmdStop_Click()
bolCancel = True
End Sub

 
That was actually my first though before my last post, but for some reason I thought something about it wouldn't work.

I can't even remember why now and it looks to me like that will do it Jeff.

 
Yes. This looks promising. I am not at the office now to give this a whirl, nut will do first thing and report back.

Thanks.

-SNT
 
I get a compilation error when I try to create the array.

Code:
Dim theWindows(4) as frmDisplay

Expects end of statement.
 
Have you actually got a form called frmDisplay in your project?

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Then there is nothing wrong with that statement, possibly the one before it?

Post all code to make it easy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top