は、ビデオとイメージングもののためAForgeを試してみることにしたので、私はthis simple demoを実装しようとした:PictureBoxを更新するときに、何がArgumentExceptionを引き起こす可能性がありますか?
private void Main_Load(object sender, EventArgs e)
{
// enumerate video devices
FilterInfoCollection videoDevices = new FilterInfoCollection(
FilterCategory.VideoInputDevice);
// create video source
VideoCaptureDevice videoSource = new VideoCaptureDevice(
videoDevices[0].MonikerString);
// set NewFrame event handler
videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
// start the video source
videoSource.Start();
}
private void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
this.pictureBox1.Image = eventArgs.Frame;
}
問題は、私はいつもArgumentException
を得ることである、しかし常にすぐに発生しません。それはApplication.Run(new Main());
にポップアップしますが、スタックトレースの先頭には、次のようになります。
at System.Drawing.Image.get_Width() at System.Drawing.Image.get_Size()
at System.Windows.Forms.PictureBox.ImageRectangleFromSizeMode(PictureBoxSizeMode mode)
at System.Windows.Forms.PictureBox.OnPaint(PaintEventArgs pe)
これは関連性があるかどうかわからしかし、のParamName
属性ではありません例外はnullです。私はtry ... catchブロックでイメージ割り当てをラップしようとしましたが、これは役に立たなかった。また、割り当て前に画像がヌルでないことを確認しました。私もnullではないが、0x0サイズの画像をチェックしました。
どうしたのですか?誰かが回避策を提案できますか?
例外のメッセージは何ですか? –
@DavidNelson良い質問:「パラメータが無効です。」 –
設定すると、eventArgs.Frameの高さと幅はどのくらいですか? –