Use webcam without screen display using python-zbar

When using a webcam via SSH on a Raspberry Pi on the network, if you set proc.init (device) as in the sample, an error will occur because the screen cannot be displayed.

 proc.init(device)
 zbar.SystemError: ERROR: zbar processor in zbar_processor_init():
 system error: spawning input thread: Invalid argument (22)

It's okay to add the -X option to SSH, but in many cases the screen display is not necessary as an application in the first place, so a memo of how to deal with such cases.

import zbar
proc = zbar.Processor()
device = '/dev/video0'
proc.init(device, False)

According to this article, although it is not documented, the device name and False are used to initialize the Processor. I should give it.

reference

Recommended Posts

Use webcam without screen display using python-zbar
Modulo without using%
Bubble sort without using sort
Write FizzBuzz without using "="
Quicksort without using sort
pyenv, virtualenv Use docker to manage the environment without using