1

I am looking for a way to capture images from my webcam using directshow, preferably I want to use HD resolutions if possible, and avoid CPU spikes at 60-100%.

can someone shoot me in the right direction on how to do this?

I tried using DSPack, but this component makes my CPU spike 90-100%

if however someone here know how to use DSPack with less CPU consumption I would also be happy about that :)

vbence
  • 20,084
  • 9
  • 69
  • 118
Plastkort
  • 957
  • 1
  • 26
  • 40
  • Before looking for Delphi solutions, are you sure it's even possible? Video compression is heavy on the CPU. Have you seen it done with any other software? There are hardware cards that do both capture and compression on-board and give the app H.264 video. – Cosmin Prund Feb 11 '11 at 13:31
  • 2
    Maybe you have an old single-core CPU? – Andreas Rejbrand Feb 11 '11 at 13:37
  • Can you clarify whether you want to capture static images (snapshots) or video clips? – LightBulb Feb 11 '11 at 18:30
  • 1
    Whats the problem with using 60 - 100% of cpu? Is it using this for a long time? – Toby Allen Feb 11 '11 at 19:14
  • 2
    DSPack does *not* cause your CPU to spike. DSPack is a wrapper around DirectShow. The encoder you are using is probably causing the CPU spike. So you should probably try a few different encoders. – GrandmasterB Feb 11 '11 at 20:56
  • I want only to preview the video, and capture a single image, I would not need to compress the video, that would only affect the quality of the captured image? – Plastkort Feb 12 '11 at 13:18

2 Answers2

2

I have a real-time video application that uses Mitov's VideoLibrary. It's a collection of objects that are well-designed, threaded, and takes advantage of all the CPU cores available.

When I go to his library with some new need, I'm usually pleasantly surprised to see he anticipated it. Support has been very good also.

It's not cheap: $450, but for my needs, has been worth every penny. It's free for non-commercial use: http://www.mitov.com/html/videolab.html.

His CaptureBitMap demo captures successive frames to a bitmap. You simply drop several components on a form, and write six lines of code! The library has lots of hooks to go further than this simple example. (In Win 7, Delphi 2010, the demos are installed here: C:\Program Files (x86)\Embarcadero\RAD Studio\7.0\LabPacks\Demos\Delphi2010\VideoLab\CaptureBitmap. But, I know he supports as far back as Delphi 7.)

One thing that differentiates his library is that it makes use of the Intel IPP libraries: http://software.intel.com/en-us/articles/intel-ipp. When running on Intel chipsets, if you choose to ship the Intel DLLs, you get the best performance that Intel's engineers could squeeze out of their chips. If Mitov's library with IPP can't process your video fast enough, I'd be surprised if any video library can.

Mitov has some standing in the Delphi community: he was a speaker on multi-threading at CodeRage: http://www.embarcadero.com/coderage5/sessions (Thursday session.)

The above may sound like I'm a shill for his company. I don't have any relationship other than as a very pleased licensee. I'm just very happy (and relieved) that I found his tools and decided to use them.

RobertFrank
  • 7,332
  • 11
  • 53
  • 99
2

I've used dspack for a long time on cheap machines that are built into cars. They have slow ~700mhz VIA processors (single core), and 256MB of RAM.

The application captures 12 images per second from a camera on the roof of the car, and every time a new GPS position (once per second) comes in, it adds coordinates to the image, and stores it as a .jpg on a harddisk.

When the application captures images, and shows the images on a form without creating .jpg images, the application takes about 5% processor time (!).

If you get 90% CPU time with DsPack, it's probably because of extra processing that's being done with the images.

I've tried all sorts of libraries in my research to create this program, and dspack was a clear winner on many fronts. I wouldn't give up on it too soon.

Wouter van Nifterick
  • 23,603
  • 7
  • 78
  • 122