How to execute device camera from main form to another form using Aforge direct show in C#? -


i have problem in executing device main form form use combo box select device, after select device main form click button open form, form has button start when click it, should start run camera without selecting device anymore because did in main form got exception saying.

"object reference not set instance of object."

this code other form.

private void start_click_1(object sender, eventargs e)         {             if (start.text == "&start")             {                 if (deviceexist)                 {                     frmmain cam = new frmmain();                     videosource = new videocapturedevice(videodevices[cam.combobox1.selectedindex].monikerstring); // exception shows here!                     videosource.newframe += new newframeeventhandler(video_newframe);                     closevideosource();                     videosource.desiredframesize = new size(160, 120);                     //videosource.desiredframerate = 10;                     videosource.start();                     lblstat.text = "device running...";                     start.text = "&stop";                 }             }         } 

what think problem here?

frmmain cam = new frmmain(); videosource = new videocapturedevice(videodevices[cam.combobox1.selectedindex].monikerstring); 

you create new instance of frmmain cam = new frmmain() , access cam.combobox1.selectedindex default -1. causes error


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -