go-opencv / go-opencv

Go bindings for OpenCV / 2.x API in gocv / 1.x API in opencv
BSD 3-Clause "New" or "Revised" License
1.32k stars 198 forks source link

The node does not represent a user object #59

Open kaikuehne opened 8 years ago

kaikuehne commented 8 years ago

Hi! I have a problem using go-opencv to load a haarcascade xml file. I'm using Mac OS and installed opencv 2.4.12 using homebrew.

I created a small file to show the error:

package main

import (
    "fmt"
    "os"

    "github.com/lazywei/go-opencv/opencv"
)

const (
    faceDetectionHaarCascade = "/usr/local/Cellar/opencv/2.4.12/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml"
)

func main() {
    _, err := os.Stat(faceDetectionHaarCascade)
    if err != nil {
        fmt.Println(err)
        os.Exit(1)
    }
    cascade := opencv.LoadHaarClassifierCascade(faceDetectionHaarCascade)
    fmt.Println(cascade)
}

The error I'm getting is:

OpenCV Error: Unspecified error (The node does not represent a user object (unknown type?)) in cvRead, file /tmp/opencv20151016-70353-1g57fur/opencv-2.4.12/modules/core/src/persistence.cpp, line 5008
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /tmp/opencv20151016-70353-1g57fur/opencv-2.4.12/modules/core/src/persistence.cpp:5008: error: (-2) The node does not represent a user object (unknown type?) in function cvRead

SIGABRT: abort
PC=0x7fff9cd3c0ae m=0
signal arrived during cgo execution

goroutine 1 [syscall, locked to thread]:
runtime.cgocall(0x4002560, 0xc82005de88, 0x0)
    /usr/local/Cellar/go/1.5.1/libexec/src/runtime/cgocall.go:120 +0x11b fp=0xc82005de40 sp=0xc82005de10
github.com/lazywei/go-opencv/opencv._Cfunc_cvLoadHaarClassifierCascade(0x5616970, 0x100000001, 0x0)
    ??:0 +0x3a fp=0xc82005de88 sp=0xc82005de40
github.com/lazywei/go-opencv/opencv.LoadHaarClassifierCascade(0x4160ca0, 0x59, 0x6464238)
    /Users/kai/Projects/go/src/github.com/lazywei/go-opencv/opencv/cvaux.go:61 +0x8d fp=0xc82005dec0 sp=0xc82005de88
main.main()
    /Users/kai/Projects/go/src/bitbucket.org/kaikuehne/opencv-test/main.go:20 +0x11d fp=0xc82005df50 sp=0xc82005dec0
runtime.main()
    /usr/local/Cellar/go/1.5.1/libexec/src/runtime/proc.go:111 +0x2b0 fp=0xc82005dfa0 sp=0xc82005df50
runtime.goexit()
    /usr/local/Cellar/go/1.5.1/libexec/src/runtime/asm_amd64.s:1696 +0x1 fp=0xc82005dfa8 sp=0xc82005dfa0

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    /usr/local/Cellar/go/1.5.1/libexec/src/runtime/asm_amd64.s:1696 +0x1

rax    0x0
rbx    0x6
rcx    0x7fff5fbee4b8
rdx    0x0
rdi    0x50f
rsi    0x6
rbp    0x7fff5fbee4e0
rsp    0x7fff5fbee4b8
r8     0x4
r9     0x7fff9943ba53
r10    0x8000000
r11    0x206
r12    0x7fff5fbee640
r13    0x5700828
r14    0x7fff7e0e7000
r15    0x7fff5fbee520
rip    0x7fff9cd3c0ae
rflags 0x206
cs     0x7
fs     0x0
gs     0x0

Can you tell me what I might have done wrong? Or is this a bug? Thanks!

dancrew32 commented 7 years ago

@kaikuehne, did you ever resolve this? I'm currently trying to load a haarcascade_frontalcatface.xml into smartcrop that dumps this error. It's weird because haarcascade_frontalface.xml and several other xml files work, but this cat face detection crash is killing me.

The node does not represent a user object

https://github.com/lazywei/go-opencv/blob/master/opencv/cvaux.go#L61

haarCascade.cascade = C.cvLoadHaarClassifierCascade(C.CString(haar), C.cvSize(1, 1))

Here's the xml file for reference: https://github.com/opencv/opencv/blob/master/data/haarcascades/haarcascade_frontalcatface.xml