Hello ,

I have been trying to use nim's opencv wrapper provided on github 
[https://github.com/dom96/nim-opencv/blob/master/tests/camera.nim](https://github.com/dom96/nim-opencv/blob/master/tests/camera.nim).
 Code provided in _opencv /tests/camera.nim_ works fine but i have not found a 
way to get the _image /frame_ data into a nim's _sequence /array_. It is my 
understanding that default arguments are `width:640 ,height:480 , channels:3` 
resulting in `921600` bytes of data .But the length of data is not constant and 
is generally less than 921600 bytes.

Resulting type of _image /frame_ as found in 
[https://github.com/dom96/nim-opencv/blob/master/opencv/types.nim](https://github.com/dom96/nim-opencv/blob/master/opencv/types.nim)
 :
    
    
    type
      TIplImage* {.pure, final.} = object
        nSize*: cint              # sizeof(IplImage)
        id*: cint                 # version (=0)
        nChannels*: cint          # Most of OpenCV functions support 1,2,3 or 4 
channels
        alphaChannel*: cint       # Ignored by OpenCV
        depth*: cint # Pixel depth in bits: IPL_DEPTH_8U, IPL_DEPTH_8S, 
IPL_DEPTH_16S,
                     #                               IPL_DEPTH_32S, 
IPL_DEPTH_32F and IPL_DEPTH_64F are supported.
        colorModel*: array[0..4 - 1, char] # Ignored by OpenCV
        channelSeq*: array[0..4 - 1, char] # ditto
        dataOrder*: cint # 0 - interleaved color channels, 1 - separate color 
channels.
                         #                               cvCreateImage can only 
create interleaved images
        origin*: cint             # 0 - top-left origin,
                                  #                               1 - 
bottom-left origin (Windows bitmaps style).
        align*: cint              # Alignment of image rows (4 or 8).
                                  #                               OpenCV 
ignores it and uses widthStep instead.
        width*: cint              # Image width in pixels.
        height*: cint             # Image height in pixels.
        roi*: ptr TIplROI          # Image ROI. If NULL, the whole image is 
selected.
        maskROI*: ptr TIplImage    # Must be NULL.
        imageId*: pointer         # "           "
        tileInfo*: ptr TIplTileInfo # "           "
        imageSize*: cint # Image data size in bytes
                         #                               
(==image->height*image->widthStep
                         #                               in case of interleaved 
data)
        imageData*: cstring       # Pointer to aligned image data.
        widthStep*: cint          # Size of aligned image row in bytes.
        borderMode*: array[0..4 - 1, cint] # Ignored by OpenCV.
        borderConst*: array[0..4 - 1, cint] # Ditto.
        imageDataOrigin*: cstring # Pointer to very origin of image data
                                  #                               (not 
necessarily aligned) -
                                  #                               needed for 
correct deallocation
    
    
    Run

The extra code i used to get the data looks as this:
    
    
       . . . . . .
       . . . . . .
      var frame = queryFrame(capture)
      var imgData =  cast[seq[uint8]](toSeq($frame.imageData))
      echo("len of imgData: ",imgData.len)
     
    
    Run

Is there something that i am missing?? 

Reply via email to