473,396 Members | 1,655 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,396 software developers and data experts.

Loop problem in capturing image using webcam

7
Hi,

I've application to capture video of image and grab the still image. It runs well until I put loop to regrab the still images many times automatically. It gives one exception error:
NullReferenceException was unhandled  ”Object reference not set to an instance of an object".
I found that, this error come out because of calling file from outside of the main code of the programming.
These are the code that calling file from the outside of the main body of code programming.

-------------------------------------------------------------------------------------------------------------------

//// apply filter subtract===>>>> call file from out bin folder <<<<=====
System.Drawing.Bitmap subtract = filter1.Apply(image2);
.
.
.

// =====>>> call file ScanFirstStage <<<========
//// create filter for extraction
string scanning = "";
////apply filter for extraction
ClassFirstStage.ScanFirstStage filter3 = new ClassFirstStage.ScanFirstStage(binary, out scanning);
objectCount1.Text = scanning;
.
.
.
// ========>>> call file Scan2ndStage <<<=========
// create filter for extraction
string scanning2 = "";

//apply filter for extraction
Class2ndStage.Scan2ndStage filter7 = new Class2ndStage.Scan2ndStage(horImage, out scanning2);
objectCount2.Text = scanning2;

-------------------------------------------------------------------------------------------------------------------

I’m using C# express edition. Could anybody help me please..
Jan 6 '07 #1
3 2121
Hi,

I've application to capture video of image and grab the still image. It runs well until I put loop to regrab the still images many times automatically. It gives one exception error:
NullReferenceException was unhandled  ”Object reference not set to an instance of an object".
I found that, this error come out because of calling file from outside of the main code of the programming.
These are the code that calling file from the outside of the main body of code programming.

-------------------------------------------------------------------------------------------------------------------

//// apply filter subtract===>>>> call file from out bin folder <<<<=====
System.Drawing.Bitmap subtract = filter1.Apply(image2);
.
.
.

// =====>>> call file ScanFirstStage <<<========
//// create filter for extraction
string scanning = "";
////apply filter for extraction
ClassFirstStage.ScanFirstStage filter3 = new ClassFirstStage.ScanFirstStage(binary, out scanning);
objectCount1.Text = scanning;
.
.
.
// ========>>> call file Scan2ndStage <<<=========
// create filter for extraction
string scanning2 = "";

//apply filter for extraction
Class2ndStage.Scan2ndStage filter7 = new Class2ndStage.Scan2ndStage(horImage, out scanning2);
objectCount2.Text = scanning2;

-------------------------------------------------------------------------------------------------------------------

I’m using C# express edition. Could anybody help me please..

not sure the problem is "calling file from outside of the main code of the programming." I am not familiar with the above scan stuff but nevertheless, the error you are receiving is usually generated when you are calling a variable that does not exsist...for instance the title of this is "LOOP PROBLEM" and I don't see any looping code...I would imagine that your loop statement has a problem like this example...

for each i as object in myArray
return myArray(2)
next i

the problem with the above example, is that "myArray(2)" may not exsist. The proper way to return this variable is...

for each i as object in myArray
return myArray(i)
next i

I am not saying yours looks anything like my examples, but look for a place in your code where you are defining a variable that should not be defined "statically".

Hope this helps. If not let me know or submit more of your code for review.

peace
Jan 6 '07 #2
nor
7
not sure the problem is "calling file from outside of the main code of the programming." I am not familiar with the above scan stuff but nevertheless, the error you are receiving is usually generated when you are calling a variable that does not exsist...for instance the title of this is "LOOP PROBLEM" and I don't see any looping code...I would imagine that your loop statement has a problem like this example...

for each i as object in myArray
return myArray(2)
next i

the problem with the above example, is that "myArray(2)" may not exsist. The proper way to return this variable is...

for each i as object in myArray
return myArray(i)
next i

I am not saying yours looks anything like my examples, but look for a place in your code where you are defining a variable that should not be defined "statically".

Hope this helps. If not let me know or submit more of your code for review.



peace

Hi,

Thanks for your reply. Sorry for the vague question. Actually the reason why I call it loop problem is because, the application of program can runs well before I put loop in the code programming. Only after I put loop code, than this problem happend.

this the code of the loop

[
private void toolBar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
if (e.Button == toolBarBtnGrab)

do
{
Thread.Sleep(500);
a++;
this.CaptureImage();
textBox1.Text = a.ToString();
Application.DoEvents();
}
while (a %10 != 0);
}
]

And, after some experiment, I found that, the error will not come out if there are no call any file from outside of the main code of programming.
And the code of calling the file from outside of main programming is like I've show previously.
I hope you still can solve this problem. Plz email me (syuhadanor@yahoo.com) if you need to see more than this. Thanks in advance.
Jan 6 '07 #3
nor
7
Hi Jake,

I've send the code to you. I hope you receive it. Pls ask if you have problem to open it.
Jan 9 '07 #4

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

Similar topics

1
by: bborden | last post by:
Novice Access programmer here. I would like to display an image using the Toolbox Image object by calling the images file name using: =fPictureFiles(!!,1) in the Picture control. Below...
1
by: Prasad More | last post by:
Hello, I am trying to write a text on Multi-page TIFF image using C# and .NET GDI+. I have written following code to do this. When I execute this code I get "Invalid Parameter User. at...
1
by: Mamatha | last post by:
Hi I want to develop a small application in C#.net . I want to display video using webcam in C#.net application,how can i code this? I am very new to C#.net,please give me any related links or...
3
by: Senthil | last post by:
Hi all I'm new in ajax. How to upload a image using ajax..
2
by: vssp | last post by:
hi friends Now I am assigned new task. But i dont know Its possible or not.Please advise When user saw the Product using webcam the prodect details (name ,make model etc....)are displaying...
2
by: labby | last post by:
I've application to capture video of image and grab the still image. It runs well untill I put loop to regrab the still images many times automatically.. and the error (generic error occured GDI+)...
0
by: indhu | last post by:
Hi all, am new to the VB forum. Anyway, i need a help from u all. i am developing project.where i am using some kind of webcam. capture image thru webcam by cliking capture button in the form. ...
2
by: user | last post by:
Hi all... i am trying to print an image using GDI - but the only thing i get is a black rectangle. Does anybody know what is wrong, or how else to get the bitmap on the printer (GDI+ is not...
11
by: shapper | last post by:
Hello, I am displaying an image on a few pages. The image size is 50 px height and 50 px width. In some pages I need the image to be 30x30 px in others 40x40 px and in others 50x50px. Can I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.