LEADTOOLS Support
Imaging
Imaging SDK Questions
how to grab an image while grabbing to a file?
This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Monday, August 7, 2006 5:26:11 AM(UTC)
Groups: Registered
Posts: 19
Hi all!
I am using the new Leadtools SDK on a FALCON grabbercard by IDS Imaging and want to save
an analog video input (PAL) to disk. But while grabbing to disk i want to make some still pictures as well.
Is there any functionality provided to grab an image while simultaneously grabbing to disk?
The SDK´s documentation is poor, no idea where to start looking for my problem.
Making still images OR making videos works fine though.
thx in advance
#2
Posted
:
Wednesday, August 9, 2006 9:42:53 AM(UTC)
Groups: Manager, Tech Support
Posts: 367
Was thanked: 1 time(s) in 1 post(s)
There are 2 ways to capture a still image without interrupting the live capture. One of them is to use 2 LEAD objects (such as Capture and Play), and take samples from one and pass them to the other. This is shown in the help topic "Capture to Play Object Interfacing".
When you want to take a still image, you can take the video sample and convert it to a bitmap for example. This part is shown in the help topic "Splitting an AVI File into Multiple Bitmaps Using ltmmSampleTarget"
Another way to get video frames is to use the LEAD Video Callback Filter. This filter calls a function you provide for every video frame, and sends it a pointer to the image data. You can write your function to copy the data or save it to disk. If the processing time of your function is fast enough, the video capture is not affected.
The toolkit is shipped with demos that use this filter. These demos use our Raster Imaging Pro toolkit, so if you don't have it, download the free evaluation edition.
Amin Dodin
Senior Support Engineer
LEAD Technologies, Inc.
#3
Posted
:
Thursday, August 10, 2006 2:02:07 AM(UTC)
Groups: Registered
Posts: 19
thx for your answer!
the 1st way as described above doesnt work properly, when i take the first picture out of the stream, and deliver it to the targetSample it works just fine, but when i try to take a second still image out of the source it always ends up in a timeout error
2nd way i havent tried yet, but is there a function provided that copies the image (which given by the pointer) as a whole to another image in the memory, or do i have to copy the image bytewise (720*576) manually?
and another question appeared:
- what exactly is stored in the CaptureCtr.TargetArray? Image data? its an one dim array of bytes, do i have access to image data here?
and can i use targetArray and TargetFile at the same time?
thx in advance
#4
Posted
:
Sunday, August 13, 2006 9:32:56 AM(UTC)
Groups: Manager, Tech Support
Posts: 367
Was thanked: 1 time(s) in 1 post(s)
In the first approach, the idea is to call:
Set MediaSample = SampleTarget.GetSample(1000)
Then take the still image from MediaSample if neede, then call:
SampleSource.DeliverSample 1000, MediaSample
About copying image data, there should be a function to copy all the data in one call, which depends on your programming environment and the type of the destination you want to copy to.
About the capture control target, with TargetArray, it must be a Variant containing a 1-dim Byte array. You can access its byte data like a normal Varian byte array. For Visual Basic and Visual C++, this is shown in our help files.
You cannot set two targets for the same capture control at the same time.
Amin Dodin
Senior Support Engineer
LEAD Technologies, Inc.
#5
Posted
:
Thursday, August 17, 2006 12:07:34 AM(UTC)
Groups: Registered
Posts: 19
This is how I tried to pass data from source to target:
// init:
.....
sampleSource = new LTMMLib.ltmmSampleSource();
sampleTarget = new LTMMLib.ltmmSampleTarget();
mediaType = new LTMMLib.ltmmMediaType();
captureControl.TargetObject = sampleTarget;
captureControl.StartCapture((int)LTMMLib.ltmmCapture_Mode.ltmmCapture_Mode_Video);
object varPortableType = sampleTarget.GetConnectedMediaType().GetPortableType();
mediaType.SetPortableType(varPortableType);
sampleSource.SetMediaType(mediaType);
playControl.SourceObject = sampleSource;
.....
private void takePicButton_Click(object sender, EventArgs e)
{
....
takePicture();
}
private void takePicture()
{
captureControl.Preview = false;
if (!recording)
{
captureControl.StartCapture((int)LTMMLib.ltmmCapture_Mode.ltmmCapture_Mode_Video);
}
sampleSource.DeliverSample(1000, sampleTarget.GetSample(1000)); //HERE THE TIMEOUT OCCURS
....
}
The timeout occurs when I hit the takePicButton the second time. I have already tried different timeouts.
another problem:
framerate of pal should be 25 fps, so i configured captureControl.Framerate = 25; but the vids still have a framerate of 29 frames...
thx in advance
#6
Posted
:
Monday, September 4, 2006 8:29:12 AM(UTC)
Groups: Manager, Tech Support
Posts: 367
Was thanked: 1 time(s) in 1 post(s)
First, try to get the "Capture to Play Control Interfacing Example" code to work without any changes. Once you do that, replace the Play control with a Convert control and try to get vide saved with minimal changes.
If you reach that far, begin with other changes, such as using all 3 controls, and extracting individual bitmaps.
Amin Dodin
Senior Support Engineer
LEAD Technologies, Inc.
#7
Posted
:
Thursday, September 7, 2006 4:36:17 AM(UTC)
Groups: Registered
Posts: 19
thx for your answer!
in the meanwhile i have tried the second approach (UserCallBack):
public class Recorder : GreyBoxListener, LMVCallbackLib.ILMVUserCallback
{
public void ReceiveProc(int pData, int lWidth, int lHeight, int lBitCount, int lSize, int bTopDown)
{
imageBuffer[ImageIndex % 25] = new Bitmap(lWidth, lHeight, lBitCount /
8, Format24bppRgb, (IntPtr)pData);
ImageIndex++;
}
....
The framerate is 25.
I suppose "new Bitmap(...) is far too slow for my image processing, cause even the preview of the capture control is no longer available when ReceiveProc is active.
Do you have an idea how to get the image data in my imageBuffer array (can be of any type) faster?
thx in advance
#8
Posted
:
Wednesday, September 13, 2006 7:28:31 AM(UTC)
Groups: Manager, Tech Support
Posts: 367
Was thanked: 1 time(s) in 1 post(s)
If Bitmap in this case is System.Drawing.Bitmap, you can try a different approach to see if it's faster. Our DrawOnVideo demo uses the callback filter to create LEADTOOLS images of type IRasterImage. You can try this approach instead to see if it gives any performance improvements. The demo is installed in the following location:
[LEADTOOLS Multimedia 15 folder]\Examples\Ltmm\Dotnet\v??\CS\DrawOnVideo
Note that to use this demo, you will need LEADTOOLS Raster Imaging Pro for .NET v14.5. If you don't have it, you can download a free evaluation edition from our site.
Amin Dodin
Senior Support Engineer
LEAD Technologies, Inc.
#9
Posted
:
Tuesday, September 19, 2006 3:07:53 AM(UTC)
Groups: Registered
Posts: 19
Thx, this helped a lot. Now capturing AND "taking pictures" works fine.
Another problem was that previewing while having the deinterlacer active caused a 2-3 sec delay.
In fullscreen mode the delay is even worse.
So previewing in an interlaced way would be no problem as long as the video images are stored in a deinterlaced way.
There are some preview tap options available, but "Source" option makes the video preview black, "Compressor" preview is too slow, and "Processor" preview tap causes the above mentioned delay.
Is there a possibility to have the deinterlacer on the video but not on the preview?
Or even better: is there a possibility to get the deinterlacer + preview working without delays?
thx in advance (again)
I hope I do not cause too much delay within your work!
#10
Posted
:
Wednesday, September 20, 2006 12:22:26 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
Setting the PreviewTap to Source should solve the problem. When I
try it here it works fine. If you select our Screen Capture
filter as the capture source do you get a black preview as well?
#11
Posted
:
Wednesday, September 20, 2006 1:26:10 AM(UTC)
Groups: Registered
Posts: 19
Setting the previewTap to source while using Screen Capture filter works fine, but unfortunately it does not work when I use my device.
I have already tried your "Multimedia Capture Demo". Even here the previewTap - Source does not work (but does with Screen Capture Filter)
The source is standard PAL, sync = 175 mV, RGB24, 768*576, 25 fps, S-Video Input
#12
Posted
:
Thursday, September 21, 2006 5:49:13 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
I can't think of a reasonable explanation for this. Can you
please check the filter graph in both cases (i.e. when using the screen
capture filter and your own device) and see if there is any difference
between them?
Here is how to do it:
Call ltmmCaptureCtrl.EditGraph rigth after you start capturing (make
sure that the PreviewTap is set to Source). A small message box
will appear; do not close it. Open GraphEdit and go to
"File->Connect to Remote Graph". Select the graph from the
dialog that shows up and press OK. Make a screen shot of each
graph and post it.
#13
Posted
:
Thursday, September 21, 2006 11:25:35 PM(UTC)
Groups: Registered
Posts: 19
ok here are the screenshots:
GrUResS attached the following image(s):
#14
Posted
:
Sunday, September 24, 2006 11:32:19 PM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
The only difference I see is that your driver has a preview output pin
while our screen capture filter doesn't, so a Smart Tee filter is
needed. The only possibility I can think of is that the preview
pin of your driver may not be working. Please try manually
creating a filter graph that includes only your driver and a renderer
attached to the preview pin. Play the graph and see what you get.
#15
Posted
:
Wednesday, October 4, 2006 4:17:28 AM(UTC)
Groups: Registered
Posts: 19
i had to reinstall my grabber hardware due to technical issues....but suddenly the preview works fine! Even with Deinterlace and Callback Filters attached....i suppose there were some driver conflicts...
thx for your support....there is only one thing left that needs to get fixed:
The Capture Control should grab images 25 frames per second, but actually does grab 29 fps....dont know how this comes...
capturecontrol.FrameRate is set to 25, input siganl is standard PAL.
thx in advance
#16
Posted
:
Monday, October 9, 2006 2:29:17 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
Do you get the same thing with the Screen Capture filter or any other
capture device? Also, which version of the SDK are you
using? Is it v14.5 or 15?
#17
Posted
:
Monday, October 9, 2006 5:24:19 AM(UTC)
Groups: Registered
Posts: 19
all settings concerning framerate do not take effect, neither on Screen Capture filter nor on my device. I tried to set screen capture fps to 25 but still captured 30 fps as this appears to be the default value.
Also the demos shipped with the evaluation version do not capture at the set frame rate
I use Lead Main Eval 14.5
#18
Posted
:
Sunday, October 15, 2006 2:46:08 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
I get the same thing when I set the FrameRate property. However,
if I set the rate from the capture filter's dialog it works as
expected. Please try that and see if it works. Call
ShowDialog to show the capture device's dialog.
#19
Posted
:
Wednesday, October 18, 2006 3:05:14 AM(UTC)
Groups: Registered
Posts: 19
unfortunately there is no way to force a certain framerate through the capture device dialog.
Options included are:
- graphical equalizer
- sync value (75 mV or 125 mV ..is set to 125)
- video input (Composite or S-Video ..is set to S-Video)
- video standard (PAL or NTSC ..is set to PAL...should be 25 fps)
- color format (is set to RGB24)
- picture size (set to 100% = 768*576)
- "scaler" or "fields" ..is set to scaler, if i choose the "fields" option there is no preview available
mhm...doesnt seem there is a way to fix this problem
thx
#20
Posted
:
Thursday, October 19, 2006 2:02:17 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
If you try to create a simple graph in Graph Edit that
contains your source driver, an AVI MUX, and a file writer, then save a short
AVI file; does it produce the correct frame rate for PAL? It might be that the
driver itself is forcing the incorrect rate.
LEADTOOLS Support
Imaging
Imaging SDK Questions
how to grab an image while grabbing to a file?
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.