Skip to content

Instantly share code, notes, and snippets.

@haarts
Created November 16, 2012 15:01
Show Gist options
  • Save haarts/4087976 to your computer and use it in GitHub Desktop.
Save haarts/4087976 to your computer and use it in GitHub Desktop.
Read a Photo with libccv
package main
/*
#include "ccv.h"
*/
import "C"
import (
"fmt"
"unsafe"
)
type Image struct {
image *C.ccv_dense_matrix_t
}
func main() {
fmt.Println("boe")
image := new(Image)
src := C.CString("painting.jpg")
defer C.free(unsafe.Pointer(src))
C.ccv_read_impl(unsafe.Pointer(src), &image.image, C.CCV_IO_GRAY|C.CCV_IO_ANY_FILE, 0, 0, 0)
dst := C.CString("black_and_white_painting.jpg")
defer C.free(unsafe.Pointer(dst))
x := 0
y := 0
C.ccv_write(image.image, dst, (*C.int)(unsafe.Pointer(&x)), C.CCV_IO_PNG_FILE, unsafe.Pointer(&y))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment