473,394 Members | 1,811 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Webcam frame event handler stop and resume c#

i have a problem with my program. I'm using Aforge for the video stream, ZXing for the qr code decoding part, c# and windows forms.

I have set up, in the initialize function, the event handler for each frame:

[videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);

In the video_newFrame i have all the code i need in my application: it takes the frame, compute it, find the QR code, decode it, check "something" and then show a messageBox; and so on for every frame. My problem is: when i show the qr code, program computes it and the messagebox appears (with the ok button, so app should be stopped); if i get out of the camera field of view the paper with the qr code, i'm expecting that, when i will click on the ok button, it will go on in the code and the next frame will be empty (meaning without the paper with the qr code - so NO messagebox in the next frame!). But it isn't like that! The most of the times, the event handler has already fired up 1-2-3 call to the video_newframe, and that means that i will have another 1-2-3 messagebox. The code is this:

Expand|Select|Wrap|Line Numbers
  1. private void video_NewFrame2(object sender, NewFrameEventArgs eventArgs) 
  2. {
  3. Bitmap img = (Bitmap)eventArgs.Frame.Clone();
  4. var result = reader.Decode(img);
  5. if (result != null) {
  6.     if (DialogResult.OK == MessageBox.Show("hello!"))
  7.         // do something;
  8.     img.Dispose(); }
  9. }
I have tried different things: i've tried to unsubscribe from the event handler at the beginning and subscribe again at the end of video_newframe function:

Expand|Select|Wrap|Line Numbers
  1. videoSource.NewFrame -= video_NewFrame; // at the beginning, at first line
  2. ...
  3. videoSource.NewFrame += video_NewFrame; // in the if of the DialogResult, in the "// do something"
but no results.

So i tried with a bool value: i added an if statement that check if the bool value is true and if it is, it puts "bool value = false" (to avoid the next event handling), it does the stuff and if value is false it returns; then, when it is doing the stuff, in the if of the DialogResult, in the "// do something", i've put "bool = true" again. No success for me.

So my problem still remains there: i just want the function to work always; but i want, somehow, that when it finds a result (a qr code) it stops firing events for just the time needed to show only one messagebox; so, for example, stop the event handling or something like that...

Hope you can help me! Thanks in advance! :)
Apr 9 '14 #1
0 1243

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Arthur Rusdell-Wilson | last post by:
I find that in a large form (especially if there is a table within the form?) that the form is submitted to my server-side script even when a JavaScript 'onsubmit' event handler returns 'false'. ...
2
by: guy | last post by:
I have a base winform Base and a form that inherits from it Child in the base form there is an event handler for a combo box click Protected Overrideable Sub...
2
by: moondaddy | last post by:
I have an asp.net 2.0 application and put a html button on a web page. I double clicked on the button and it crated the event handler for me and created the stub js function for it like this: ...
2
by: =?Utf-8?B?Vk1J?= | last post by:
How can I stop an event handler from executing? For example, I my Gridview RowEditing event handler looks like this: protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) {...
2
dmjpro
by: dmjpro | last post by:
what concept i have that when i wrting my own event handler then if my handler returns false then the default event handler will no more execute. so i can stop the window default behaviours...
1
by: suresh_nsnguys | last post by:
Hi, i am displaying google.com website inside a frame with frameset setting onblur="self.focus();". but when i am trying to enter some text in google search box,the text is not getting...
13
tpgames
by: tpgames | last post by:
What is the onload event handler needed to get # assigned to parent variable? What I tried didn't work! Code is from JS bible, page 127-8 with some minor alterations by me. Parent Page (in part)...
4
by: eggie5 | last post by:
I have this even handler (using prototype.js): showCommentsLinks.observe('click', function(event) { alert('hi') }); It's attaching to a link element: <a id="showCommentsLink"...
0
by: das | last post by:
Hello all, I am using the SqlDependency to subscribe to any new inserts into a database table, I enabled the DB to be borker ready and subscrbed to Query notifications on the database. My C#...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.