ZBAR examples
Re: ZBAR examples
infratec, thank you very much for sharing your wrapper!
Can you give an example how to use zbar with webcam directly (without saving picture to file)?
Can you give an example how to use zbar with webcam directly (without saving picture to file)?
Re: ZBAR examples
HI,
sorry for the delay, but my code was not running in win10.
After a hour of searching I found out that libzbar-0.dll was the fault.
I downloaded then:
https://sourceforge.net/projects/zbarw/ ... p/download
and it worked.
sorry for the delay, but my code was not running in win10.
After a hour of searching I found out that libzbar-0.dll was the fault.
I downloaded then:
https://sourceforge.net/projects/zbarw/ ... p/download
and it worked.
Code: Select all
EnableExplicit
IncludeFile "ZBar.pbi"
ProcedureC data_handler(*img, *userdata)
Protected *sym, type.i, *data
Debug "data_handler"
*sym = zbar_image_first_symbol(*img)
While *sym
If zbar_symbol_get_count(*sym)
Continue
EndIf
type = zbar_symbol_get_type(*sym)
If type = #ZBAR_PARTIAL
Continue
EndIf
Debug zbar_symbol_get_data(*sym)
Debug zbar_get_symbol_name(type)
*sym = zbar_symbol_next(*sym)
Wend
EndProcedure
Define.l infmt, outfmt, display, active, rc
Define.i Result
Define *proc
Define video_device$
If ZBar_Init()
*proc = zbar_processor_create(1)
If *proc
zbar_processor_set_data_handler(*proc, @data_handler(), #Null)
video_device$ = ""
infmt = 0
outfmt = 0
display = #True
zbar_processor_request_size(*proc, 640, 480)
If infmt Or outfmt
zbar_processor_force_format(*proc, infmt, outfmt)
EndIf
If zbar_processor_init(*proc, @video_device$, display) Or (display And zbar_processor_set_visible(*proc, #True))
Result = zbar_processor_error_spew(*proc, 0)
Debug "zbar_processor_init : " + Str(Result)
End Result
EndIf
; start video
active = #True
If zbar_processor_set_active(*proc, active)
Result = zbar_processor_error_spew(*proc, 0)
Debug "zbar_processor_set_active" + Str(Result)
End Result
EndIf
; let the callback handle Data
Repeat
rc = zbar_processor_user_wait(*proc, -1)
Debug rc
If rc = 'q' Or rc = 'Q'
Break
EndIf
If rc = ' '
If active
active = #False
Else
active = #True
EndIf
If zbar_processor_set_active(*proc, active)
Result = zbar_processor_error_spew(*proc, 0)
Debug "zbar_processor_set_active" + Str(Result)
End Result
EndIf
EndIf
Until rc >= 0
If rc <> 0 And rc <> 'q' And rc <> 'Q' And zbar_processor_get_error_code(*proc) <> #ZBAR_ERR_CLOSED
Result = zbar_processor_error_spew(*proc, 0)
Debug Result
End Result
EndIf
; free resources (leak check)
zbar_processor_destroy(*proc)
Else
Debug "ERROR: unable to allocate memory?"
EndIf
EndIf
Re: ZBAR examples
Else you can use any methode to get a picture into RAM and convert it to a form which zbar understand.
Look at the example with the loaded file
I used escapi3 for things like this.
Look at the example with the loaded file

I used escapi3 for things like this.
Re: ZBAR examples
Hi, infratec!
Your examples are interesting and very useful especially to get started with zbar!
But I think it will take quite a long time to get a really working program.
There are some troubles with zbar:
1. video freezes often:
2. after updating libraries to version 20121031 an error appeared in OwnCleanUp(*image.zbar_image_s) during executing:
I think it's needed to update the functions prototypes for libraries v. 20121031
But these are the details... Thanks again for the great work!
Good luck!
Your examples are interesting and very useful especially to get started with zbar!
But I think it will take quite a long time to get a really working program.

There are some troubles with zbar:
1. video freezes often:
Code: Select all
ProcedureC data_handler(*img, *userdata)
...
While *sym
If zbar_symbol_get_count(*sym) ; <------freezes here!
Continue
EndIf
...
Wend
EndProcedure
Code: Select all
[ERROR] The specified '*MemoryID' is not valid.
But these are the details... Thanks again for the great work!
Good luck!
Re: ZBAR examples
Hi,
this windows version use a newer structure, but does not increase the version to 0.11
I updated the listing on the fisrt page
If you add the crop stuff, the IMA with OwnCleanup() is fixed.
With my webcam (Microsoft VX-6000) I get no freezes.
So I can not help you.
this windows version use a newer structure, but does not increase the version to 0.11

I updated the listing on the fisrt page
If you add the crop stuff, the IMA with OwnCleanup() is fixed.
With my webcam (Microsoft VX-6000) I get no freezes.
So I can not help you.
Last edited by infratec on Wed Nov 11, 2020 10:24 am, edited 1 time in total.
-
- Enthusiast
- Posts: 551
- Joined: Tue Oct 14, 2014 12:09 pm
Re: ZBAR examples
Hi Infratec,
I download the dll libzbar-0.dll from https://sourceforge.net/projects/zbarw/ ... p/download like you mentionned in your post and try to use ypur wrapper. Unfortunetly the l libzbar-0.dll won't want to load ?
Have you an idea ?
Thanks in advance
I am on windows 10 with the last version on Purebasic 5.73 beta 4
I download the dll libzbar-0.dll from https://sourceforge.net/projects/zbarw/ ... p/download like you mentionned in your post and try to use ypur wrapper. Unfortunetly the l libzbar-0.dll won't want to load ?
Have you an idea ?
Thanks in advance
I am on windows 10 with the last version on Purebasic 5.73 beta 4
Re: ZBAR examples
This is a x86 dll.
Did you use PB x86 ?
As written you need also libiconv-2.dll.
Is it in the same directory?
Btw. From where you downloaded beta 4
I only know beta 3
Did you use PB x86 ?
As written you need also libiconv-2.dll.
Is it in the same directory?
Btw. From where you downloaded beta 4

I only know beta 3
-
- Enthusiast
- Posts: 551
- Joined: Tue Oct 14, 2014 12:09 pm
Re: ZBAR examples
[quote="infratec"]This is a x86 dll.
Did you use PB x86 ? Yes
As written you need also libiconv-2.dll.
Is it in the same directory? Yes
Btw. From where you downloaded beta 4 ?: I only know beta 3 Sorry i use PB 5.73 beta 3
I try to FreeMemory(*image\Data)
launch with n older version of PB (PB 5.72) It works but i have an error on following lines
Did you use PB x86 ? Yes
As written you need also libiconv-2.dll.
Is it in the same directory? Yes
Btw. From where you downloaded beta 4 ?: I only know beta 3 Sorry i use PB 5.73 beta 3
I try to FreeMemory(*image\Data)
launch with n older version of PB (PB 5.72) It works but i have an error on following lines
Code: Select all
Ligne 947 FreeMemory(*image\Data) l'argument *MemoryId spécifié n'est pas valide
Re: ZBAR examples
Do you use the fix from above?
I will try it today with 5.73b3
Code: Select all
Structure zbar_image_s
-
- Enthusiast
- Posts: 551
- Joined: Tue Oct 14, 2014 12:09 pm
Re: ZBAR examples
Result finally I put the new structure in my programm and execute it . It works wel. With PB 6.75 beta 3 the problem is always the same.infratec wrote:Do you use the fix from above?I will try it today with 5.73b3Code: Select all
Structure zbar_image_s
- Jac de Lad
- Enthusiast
- Posts: 106
- Joined: Wed Jul 15, 2020 7:10 am
- Contact:
Re: ZBAR examples
Wow, you're the first time traveller I've met! I love such typos...loulou2522 wrote:PB 6.75 beta 3
Re: ZBAR examples
I just tested it with PB 5.73 beta 3 x86 on Windows 10 x64:
I had to comment in the Align #PB_Structure_AlignC at the Structure zbar_image_s
I copied my complete file to my post on page 1.
Please copy the complete file as new zbar.pbi.
I had to comment in the Align #PB_Structure_AlignC at the Structure zbar_image_s
I copied my complete file to my post on page 1.
Please copy the complete file as new zbar.pbi.
Re: ZBAR examples
@infratec, thank you very much for the include and sample.
Selecting a video source and taking a qr code by camera works well.
Could you please help with the following further questions, too ?
- when user closes scan window, the zbar_processor_user_wait seems still to be active
If I change line 82 to the loop will be leaved, but then an IMA occurs
- is there a way to retrieve the available videosources ? This would allow to pass video_device$ to zbar_processor_init() in order to avoid the user needing to select the camera every time again
- is there a way to enable the green/red detection rectangles (as shown in zbarcam.exe), when a barcode is detected ?
Thank you and kind regards
Oli
Selecting a video source and taking a qr code by camera works well.
Could you please help with the following further questions, too ?
- when user closes scan window, the zbar_processor_user_wait seems still to be active
If I change line 82 to
Code: Select all
If rc = 'q' Or rc = 'Q' Or rc=-1
- is there a way to retrieve the available videosources ? This would allow to pass video_device$ to zbar_processor_init() in order to avoid the user needing to select the camera every time again
- is there a way to enable the green/red detection rectangles (as shown in zbarcam.exe), when a barcode is detected ?
Thank you and kind regards
Oli
Re: ZBAR examples
Hi Oliver,
my zbar stuff is now nearly 4 years old and I don't use it since years, since I use now an other tool to decode QRCode.
I just tried to run my code with PB 6.11 and it is not runing.
At the moment I have no time to deep dive into zbar stuff.
But I think there are some C examples available which shows how this can be achieved.
my zbar stuff is now nearly 4 years old and I don't use it since years, since I use now an other tool to decode QRCode.
I just tried to run my code with PB 6.11 and it is not runing.
At the moment I have no time to deep dive into zbar stuff.
But I think there are some C examples available which shows how this can be achieved.