最終更新:
edward_black 2013年11月17日(日) 22:16:09履歴
- Menustrip, Panel, OpenCvSharp.UserInterface.PictureBoxIpl
- 設計2
![](https://static.seesaawiki.jp/formatter-storage/images/function/fukidashi/icon_guest.gif)
Sobel, Canny, LaplaceはOpenCvSharpにある既存のメソッドを用います
- こちらのブログ:大山昇太の今日このごろ に、丁寧な解説があります。
- エッジ検出処理自体は"Cv.Canny", "Cv.Sobel", "Cv.Laplace" で行います。これらメソッドに必要なパラメータを動的に変更できるようにするため、ソースが長くなっています。
![](https://image02.seesaawiki.jp/i/g/image_processing/05f0fa1c9bd50053.png)
- 画像の確保
IplImage src = pictureBoxIpl1.ImageIpl;PictureBoxIplに表示した画像を操作したいため、pictureBoxIplからIplImageを作成しています。
ここで注意すべきはカラーチャネルで、8ビット濃淡画像を読み込みPictureBoxIplに表示した場合でも、次にPictureBoxIplからIplImageを作成するとカラーチャネルは "IplImage.NChannels = 3" となります。
Cv.Cannyの出力はチャネル数1で固定、Cv.SobelとCv.Laplaceは入力画像のチャネル数と出力画像のチャネル数が一致しなければなりませんので、注意が必要です。
- InputData_String
![](https://image02.seesaawiki.jp/i/g/image_processing/cae13c19a589d297.png)
自作のフォームです。様々なデータインプット用フォームとして利用しています。
>inputF.label1.Text = "aperture_size"; //Label Name >String[] A_aperture = { "3", "5", "7"}; //Definition type of Array String > foreach (String num in A_aperture) inputF.comboBox1.Items.Add(num); //Initialize : Add ALL Items : A_aperture -> comboBox1.Items >inputF.comboBox1.SelectedIndex = 1; //Initialize : Decide Number >while (inputF.Visible == true) //Visible Property(bool) : true = forms are displayed; otherwise false.
このデータフォームはOKボタンを押すことでHide()が実行されるため、Visibleプロパティがfalseになります。
Dispose()はフォームを終了するため、再アクセスすることはできません。そのため、再アクセスする可能性があるものは "とりあえず" Hide()にしておくと便利です。
Form form = new Form(); form.Show(); form.Dispose(); form.Show(); //ここでエラー Form form2 = new Form(); form2.Show(); form2.Hide(); form2.Show(); //OK
- TrackBarForm
![](https://image01.seesaawiki.jp/i/g/image_processing/defe59f11af09578.png)
トラックバーを羅列したフォームです(OpenCvSharp.UserInterface.TrackbarWithLabel)
その都度、ラベル名や最大値、最小値、現在値を設定します。
トラックバースクロール時にはラベル名をトラックバーの値に書き換えているため、ラベル番号を参照することで値を取得できます。
this.trackbarWithLabel1.Label.Text = this.trackbarWithLabel1.Trackbar.Value.ToString();
下部にあるTimeLimit(progressBar)は、timerの使い方を学ぶために付けてみただけであって、特に意味はありません。
リミットが来たらトラックバーを終了させるだけです。
public TrackbarForm() { InitializeComponent(); timer_TrackbarForm_Limit.Interval = 1000; progressBarTimeLimit.Maximum = 600; timer_TrackbarForm_Limit.Enabled = true; } private void timer_TrackbarForm_Limit_Tick(object sender, EventArgs e) { timer_now += timer_TrackbarForm_Limit.Interval; if ((timer_now >= 500000) && (timer_now <= 600000)) { labelTimeLimit.ForeColor = Color.Red; progressBarTimeLimit.ForeColor = Color.Red; progressBarTimeLimit.Value = (timer_now / 1000); } else progressBarTimeLimit.Value = (timer_now / 1000); if (timer_now > 600000) { this.buttonExit_Click(sender, e); // = this.Close() } }
このページへのコメント
Great topic and well written. Do you have any more resources about this
that you reccommend?
Great topic and well written. Do you have any more resources about this that you reccommend?
Great topic and well written. Do you have any more resources about this that
you reccommend?
Great topic and well written. Do you have
any more resources about this that you reccommend?
Great topic and well written. Do you have any more resources about this that you reccommend?