C# と VB.NET の質問掲示板

ASP.NET、C++/CLI、Java 何でもどうぞ

ログ内検索
  • キーワードを複数指定する場合は 半角スペース で区切ってください。
  • 検索条件は、(AND)=[A かつ B] (OR)=[A または B] となっています。
  • [返信]をクリックすると返信ページへ移動します。
キーワード/ 検索条件 /
検索範囲/ 強調表示/ ON (自動リンクOFF)
結果表示件数/ 記事No検索/ ON
大文字と小文字を区別する

No.85364 の関連記事表示

<< 0 >>
■85364  Re[13]: カメラ台数を増やす
□投稿者/ しろ -(2017/10/14(Sat) 21:52:36)
    大体ですがこんな感じです・↓
    Imports AForge.Video
    Imports AForge.Video.DirectShow

    Public Class Form1
    Dim _videoDevices1 As FilterInfoCollection
    Dim _videoDevices As FilterInfoCollection

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    '保存先の指定
    TextBox1.Text = "C:\tic\"
    'スイッチを使用禁止にする
    ' ComboBox1.Enabled = False
    Button2.Enabled = False
    Button3.Enabled = False
    Button4.Enabled = False
    Button5.Enabled = False
    'ビデオデバイス一覧を表示する
    _videoDevices = New FilterInfoCollection(FilterCategory.VideoInputDevice)

    ComboBox1.Items.Clear()
    If _videoDevices.Count <> 0 Then
    For Each device In _videoDevices
    ComboBox1.Items.Add(device.Name)
    Next
    ComboBox1.SelectedIndex = 0

    End If

    _videoDevices1 = New FilterInfoCollection(FilterCategory.VideoInputDevice)

    ComboBox2.Items.Clear()
    If _videoDevices.Count <> 0 Then
    For Each device In _videoDevices
    ComboBox2.Items.Add(device.Name)
    Next
    ComboBox2.SelectedIndex = 0
    End If


    End Sub

    Dim _videoSource As VideoCaptureDevice = Nothing
    Private ReadOnly cameraControl1 As Object
    Private ReadOnly dt As Object
    Private formatteddate As String
    Private intNUM As Integer

    わからんところ↓ビデオデバイスを画像をのComboBox2で
    選択された2代目カメラPictureBox3出力されないところ。

    'ビデオデバイス取得画像表示
    Private Sub Video_NewFrame(sender As Object, eventArgs As NewFrameEventArgs)
    Dim img = DirectCast(eventArgs.Frame.Clone(), Bitmap)
    PictureBox1.Image = img



    'ビデオデバイス取得画像表示
    ' Private Sub Video_NewFrame1(sender As Object, eventArgs As NewFrameEventArgs)
    ' Dim img1 = DirectCast(eventArgs1.Frame.Clone(), Bitmap)
    ' PictureBox3.Image = img1
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

    ここでボタンを押すとComboBox1が例えばaのPictureBox1に接続表示
    で、ComboBox1で選択された2代目がPictureBox3に出力されるようにしたいのですが
    なかなかうまくいかないです。↓

    'USBビデオデバイスに接続表示
    If ComboBox1.Items.Count = 0 Then
    Return
    End If

    Dim MonikerString = _videoDevices(ComboBox1.SelectedIndex).MonikerString '最初のビデオデバイスを使用

    _videoSource = New VideoCaptureDevice(MonikerString)
    AddHandler _videoSource.NewFrame, AddressOf Me.Video_NewFrame
    _videoSource.Start()

    'スイッチを使用可能にする
    Button2.Enabled = True
    Button3.Enabled = True
    Button4.Enabled = True
    Button5.Enabled = True


    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    'USBビデオデバイス停止
    If _videoSource Is Nothing Then
    Return
    End If

    If _videoSource.IsRunning Then
    _videoSource.SignalToStop() 'ビデオデバイスの停止
    _videoSource.WaitForStop() '完全に停止するまで待つ
    _videoSource = Nothing
    End If
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
    ' 自身のフォームを閉じる
    Me.Close()
    End
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click

    ' カウンタ
    Label2.Text = Label2.Text + 1
    '保存先を指定してjpgファぃるに保存する
    Dim ro As String = TextBox1.Text

    Dim dt = DateTime.Now
    formatteddate = dt.ToString("yyyy年MM月dd日hh時mm秒ss分")



    Dim fileName As String = ro + formatteddate + ".jpg"
    Label3.Text = formatteddate

    ' MessageBox.Show(fileName)
    PictureBox1.Image.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg)

    '
    ' FileStream を開く
    Dim hStream As New System.IO.FileStream(fileName, System.IO.FileMode.Open)

    ' FileStream から画像を読み込んで表示
    Me.PictureBox2.Image = Image.FromStream(hStream)

    ' FileStream を閉じる (正しくは オブジェクトの破棄を保証する を参照)
    hStream.Close()


    End Sub

    Private Function vrnINPUT() As String
    Throw New NotImplementedException()
    End Function

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
    'カウンタ内容を0にリセットする
    Label2.Text = "0"
    End Sub


    End Class
記事No.85265 のレス /過去ログ146より / 関連記事表示
削除チェック/



<< 0 >>

パスワード/

- Child Tree -