oaleeapp / SwiftEyes

An easy way to access OpenCV library from Swift.
https://oaleeapp.github.io/SwiftEyes/
Other
8 stars 1 forks source link

CMSampleBuffer to OCVMat #3

Open dimohamdy opened 7 years ago

dimohamdy commented 7 years ago

how i can convert CMSampleBuffer or UIImageto to OCVMat ? i try to use

        let image:UIImage = UIImage(named: "123.jpg")!
        processImage(OCVMat(image: image))
        processImage(OCVMat(image: image))

but this method in processImage crash OCVOperation.convertColor(fromSource: image, toDestination: image, with: .typeBGRA2RGBA)

oaleeapp commented 7 years ago

I found the problem is caused by image?.dims,

if you create a image like you did, the dim is 0,

but the Mat create by the camera feed, the dim is 2

(lldb) po image.dims
▿ Optional<Int>
  - some : 2

I current not sure why, but I'll find out later.

dimohamdy commented 7 years ago

ok is this problem in only from loaded image ? in my real case i will convert CMSampleBuffer to UIImage did you think this will crash too ?