Article View: borland.public.cppbuilder.nativeapi
Article #2315Re: VC++ CSemaphore equivalent?
From: Robert G. Hoover
Date: Mon, 12 Mar 2007 18:09
Date: Mon, 12 Mar 2007 18:09
85 lines
3402 bytes
3402 bytes
Hi Jon,
'busy' is unused throughout the rest of the application during execution. When
the user closes the main window, I set 'terminated' to true and wait until
'!grabbing' Sorry for the confusion. I appended the total thread loop below.
'busy' is unused. Again, included for future use, not implemented in any other
part of the program.
'grab()' calls my camera supplier's video GrabSingleFrame() call which I have
been assured but cannot validate is thread-safe.
'process()' does nothing unless check marks are set in additional GUI window. No
functions are called from this routine as no checkmarks are checked.
ex. if (VideoForm->BlurImage->Checked) BlurVideoImage();
'display()' calls SendDIBitsToDevice()
Really, these threads should run independent of each other (I hope). The parent
thread (Main Application Thread embedded in Borland's TApplication?) listens for
Windows' events (WM_MOUSEMOVE, WM_CLOSE, etc.) and the child thread
Grab-And-Display video images. I guess I have no guarantee that the actual call
to the camera hardware to fill by bit-bucket (uchar buffer) is not causing the
problem. :(
Thanks,
Rob
___________________________________________________________________________
// background thread for live video display and processing
void VideoClass::LiveVideoGrabbingThread()
{
// set semiphores
terminated = false;
busy = false;
grabbing = true;
// log event
Global_UpdateStatusPrivate(String("entering ") + __FUNC__ + "()...");
// grab, process, display live video as normal
while (!terminated)
{
// give primary thread time to process frozen image
if (frozen)
Sleep(100);
// grab, process, and display video data
else
{
// set semiphore
busy = true;
// grab video frame from camera
Grab();
// process image data
Process();
// display current image on screen
Display();
// clear semiphore
busy = false;
// preserve process time
Sleep(FrameRateTimeOut);
}
}
}
// log event
Global_UpdateStatusPrivate(String("exiting ") + __FUNC__ + "()...");
// clear semiphore allowing main process to continue
grabbing = false;
}
//---------------------------------------------------------------------------
Technical Details
Message-ID:
<45f5973e$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<45f57403@newsgroups.borland.com> <45f59433$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,411b13b57e2ea81a X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Mon, 12 Mar 2007 14:09:39 -0400 From: "Robert G. Hoover" <not.a.real.address@anywhere.sorry> User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: VC++ CSemaphore equivalent? References: <45f57403@newsgroups.borland.com> <45f59433$1@newsgroups.borland.com> In-Reply-To: <45f59433$1@newsgroups.borland.com> X-Enigmail-Version: 0.94.1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Antivirus: avast! (VPS 000723-1, 03/12/2007), Outbound message X-Antivirus-Status: Not-Tested NNTP-Posting-Host: 68.48.157.44 Message-ID: <45f5973e$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1173722942 68.48.157.44 (12 Mar 2007 11:09:02 -0800) Lines: 85 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail