c# 4.0 - The name 'InitializeComponent()' does not exist in the current context (c#, emgucv) -
i trying run code using c# , emgucv draw histogram image keeps giving me error 'the name 'initializecomponent()' not exist in current context'. tried add references not working.
using zedgraph; using system; using system.linq; using system.text; using system.drawing; using system.runtime.interopservices; using emgu.cv; using emgu.cv.cvenum; using emgu.cv.ui; using emgu.util; using emgu.cv.structure; using system.windows.forms; using system.componentmodel; using system.data; using system.io; using system.windows.markup; using system.windows; using system.windows.input; using system.windows.threading; using system.xaml; using system.xml; ; namespace my_emgu_program { public partial class form1 : form { public form1() { initializecomponent(); } private void button1_click(object sender, eventargs e) { openfiledialog openfile = new openfiledialog(); if (openfile.showdialog() == dialogresult.ok) { image<bgr, byte> img = new image<bgr, byte>(openfile.filename); float[] bluehist; float[] greenhist; float[] redhist; densehistogram histo = new densehistogram(255, new rangef(0, 255)); image<gray, byte> img2blue = img[0]; image<gray, byte> img2green = img[1]; image<gray, byte> img2red = img[2]; histo.calculate(new image<gray, byte>[] { img2blue }, true, null); //the data here //histo.matnd.managedarray bluehist = new float[256]; histo.matnd.managedarray.copyto(bluehist, 0); histo.clear(); histo.calculate(new image<gray, byte>[] { img2green }, true, null); greenhist = new float[256]; histo.matnd.managedarray.copyto(greenhist, 0); histo.clear(); histo.calculate(new image<gray, byte>[] { img2red }, true, null); redhist = new float[256]; histo.matnd.managedarray.copyto(redhist, 0); float[] grayhist; image<gray, byte> img_gray = new image<gray, byte> (openfile.filename); histo.calculate(new image<gray, byte>[] { img_gray }, true, null); //the data here //histo.matnd.managedarray grayhist = new float[256]; histo.matnd.managedarray.copyto(grayhist, 0); /*this methof call produced histograms you*/ add_histogram(grayhist, "gray histogram"); add_histogram(bluehist, "blue histogram"); add_histogram(greenhist, "green histogram"); add_histogram(redhist, "red histogram"); } } /* can extend method set line colour x , y titles quite */ //global x y locations stack histograms int x = 10, y = 10; panel panel1 = new panel(); void add_histogram(float[] histo_dat, string histo_title = "histogram title") { //create control zedgraphcontrol zgc = new zedgraphcontrol(); zgc.location = new point(y, x); zgc.size = new size(panel1.width - 20, 200); x += (zgc.size.height + 20); //increas x next graph graphpane mypane = zgc.graphpane; mypane.title.text = histo_title; mypane.xaxis.title.text = "x axis - pixel bin values"; mypane.yaxis.title.text = "y axis - total number of pixels"; //create array zedgraph can use pointpairlist list1 = new pointpairlist(); (int = 0; < histo_dat.length; i++) { list1.add(new pointpair(i, histo_dat[i])); } //add data control lineitem mycurve = mypane.addcurve("title", list1, color.blue, symboltype.circle); zgc.axischange(); //add controll , refresh form panel1.controls.add(zgc); this.refresh(); } //in case wish restart , draw newly calculated histograms void clear_histograms() { panel1.controls.clear(); x = 10; } } }
form1
partial class.
means there file form1.designer.cs contains missing method.
can't copy , paste code - need files accompany it:
form1.cs
, form1.designer.cs
, maybe resource files such form1.resx
.
suggest going through basics before attempting complicated code.
Comments
Post a Comment