Reading barcodes by using a webcam with gb.media Component

Eigene oder Gemeinschaftsprojekte, Klassen, Module, Codeschnipsel, HowTos, ...
Antworten
vuott
Foriker
Beiträge: 73
Registriert: Fr 16. Jan 2015, 01:27
Kontaktdaten:

Reading barcodes by using a webcam with gb.media Component

Beitrag von vuott » So 13. Aug 2017, 19:51

Hello,
here a code, I wrote, to read barcodes by using a webcam with gb.media Component:
gambas code
Private pl As MediaPipeline
Private tb As ToggleButton
Private drar As DrawingArea


Public Sub _new()

  With Me
    .W = 600
    .H = 600
  End With
  
  drar = New DrawingArea(Me)
  drar.Background = Color.Transparent
  
  With tb = New ToggleButton(Me) As "Tasto"
    .X = 500
    .Y = 550
    .W = 80
    .H = 40
    .Text = "Start"
  End With
  
End

Public Sub Form_Open()

  Dim src, zbr, snk As MediaControl
  
   pl = New MediaPipeline As "Pipeline"
   
   src = New MediaControl(pl, "v4l2src")
   zbr = New MediaControl(pl, "zbar")
   snk = New MediaControl(pl, "xvimagesink")
   
   src.LinkTo(zbr)
   zbr.LinkTo(snk)
   
   snk.SetWindow(drar)
  
End


Public Sub Tasto_Click()
 
 If tb.Value Then
   pl.Play()
   tb.Text = "Stop"
 Else
   pl.Stop()
   pl.Close()
   Me.Close
 Endif
 
End


Public Sub Pipeline_Event(Message As MediaMessage)
  
  Dim c As Integer

  If Message.Name = "barcode" Then
    For i = 1 To Message.count - 1
      With Message
        Print .Keys[c], Message[.Keys[c]],
      End With
    Next
    Print
  Endif
  
End
Ciao :)

Benutzeravatar
gambi
Moderator
Beiträge: 216
Registriert: Mi 8. Mai 2013, 21:46
Kontaktdaten:

Re: Reading barcodes by using a webcam with gb.media Component

Beitrag von gambi » So 13. Aug 2017, 20:20

Hi vuott,
thank you for sharing your code. 8-)
Maybe you saw my little project Gambas-Food-Info :)

Because the video jerks in my project, I added some lines:
gambas code
$hTee = New MediaControl($hPipe, "tee")
$hqueue1 = New MediaControl($hPipe, "queue")
$hqueue2 = New MediaControl($hPipe, "queue")
$hVidConv = New MediaControl($hPipe, "videoconvert")
$hFakesink = New MediaControl($hPipe, "fakesink") As "fakesink"
$hSink = New MediaControl($hPipe, "xvimagesink")
$hZBAR = New MediaControl($hPipe, "zbar")
  
  $hSource.LinkTo($hTee)                 
  
  $hTee.LinkTo($hqueue1)                 
  $hTee.LinkTo($hqueue2)                  
  
  $hqueue1.LinkTo($hVidConv)            
  $hVidConv.LinkTo($hZBAR)               
  
  $hZBAR.LinkTo($hFakesink)                   

  $hqueue2.LinkTo($hSink)                 
  $hSink.SetWindow(drar)
The equivalent in GStreamer is: gst-launch-1.0 -m v4l2src ! tee name=t ! queue ! videoconvert ! zbar ! fakesink t. ! queue ! xvimagesink

gg

vuott
Foriker
Beiträge: 73
Registriert: Fr 16. Jan 2015, 01:27
Kontaktdaten:

Re: Reading barcodes by using a webcam with gb.media Component

Beitrag von vuott » Mo 14. Aug 2017, 11:25

Hello gambi,
gambi hat geschrieben:
So 13. Aug 2017, 20:20
Maybe you saw my little project Gambas-Food-Info
No, I did not see that your project.
But now I have downloaded it.


gambi hat geschrieben:
So 13. Aug 2017, 20:20
... in my project, I added some lines:
Excuse me, I don't understand :? the addition of those lines, because - if I'm not wrong - your project does not use gb.media Component.
Can you explain it better ?


ciao :)

Benutzeravatar
gambi
Moderator
Beiträge: 216
Registriert: Mi 8. Mai 2013, 21:46
Kontaktdaten:

Re: Reading barcodes by using a webcam with gb.media Component

Beitrag von gambi » Mo 14. Aug 2017, 15:10

Hi vuott,
sorry for the confusion :?

You are right. The posted project is based on the Embedder-component. Because Embedder is outdated, I wanted to find an alternative.
In my current project - not yet published - I use gb.media too.

Isn't it funny that two projects at the same time deal with ZBAR? :P
gg

vuott
Foriker
Beiträge: 73
Registriert: Fr 16. Jan 2015, 01:27
Kontaktdaten:

Re: Reading barcodes by using a webcam with gb.media Component

Beitrag von vuott » Mo 14. Aug 2017, 20:25

gambi hat geschrieben:
Mo 14. Aug 2017, 15:10
Isn't it funny that two projects at the same time deal with ZBAR?
Yes, it is.
You and me seem like pioneers about it. :D

Ciao

Antworten

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 2 Gäste