Skip to content

A cgo wrapper around the zbar c barcode scanning library.

License

Notifications You must be signed in to change notification settings

MordFustang21/gozbar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoZBar

Fork of https://github.com/PeterCxy/gozbar due to API breaking changes.

ZBar bindings for golang. Only scanner supported.

Read the ZBar documentations for explanations on constants and arguments.

The ZBar library must be installed for this to compile.

Example JPEG Scan.

func TestPhoto(t *testing.T) {
	const expectedStr = "http://www.searchenginestrategies.com/sanfrancisco/share.html"

	f, err := os.Open("./testdata/photo.jpg")
	if err != nil {
		t.Fatal(err)
	}

	i, err := jpeg.Decode(f)
	if err != nil {
		t.Fatal(err)
	}

	img := FromImage(i)

	s := NewScanner()
	err = s.SetConfig(0, CFG_ENABLE, 1)
	if err != nil {
		t.Fatal("error setting config", err)
	}

	err = s.Scan(img)
	if err != nil {
		t.Fatal("error scanning", err)
	}

	defer s.Destroy()

	img.First().Each(func(str string) {
		if str != expectedStr {
			t.Fatalf("expected [%s] got [%s]", expectedStr, str)
		}
	})
}

About

A cgo wrapper around the zbar c barcode scanning library.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages