raw string from mmap.read() possible?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dan Jones

    raw string from mmap.read() possible?

    Hello all,

    I'm writing a webcam app to display video from a video4linux device. I'm
    having trouble with the function to convert the video from yuv420p
    format to rgb. Its a C function that I wrapped for use in python. Here's
    whats happening:

    WIDTH=320
    HEIGHT=240

    yuvframe = mmap.read(WIDTH *HEIGHT*3)
    rgbframe = yuv.yuv2rgb(WID TH, HEIGHT, yuvframe)

    At this point it gives a typeerror: argument 3 must be string without
    null bytes, not str.

    I did some testing to see whats going on. This call also generates the
    typeerror:

    rgbframe = yuv.yuv2rgb(WID TH, HEIGHT, "\0\0\0\0")

    but if I send it a raw string it doesn't complain:

    rgbframe = yuv.yuv2rgb(WID TH, HEIGHT, r"\0\0\0\0")

    I'm assuming this is happening because C interprets NULL as the end of
    the string. Is there a way to get a raw string directly from the
    mmap.read() call or do I have to do a conversion after the read? If I
    have to convert it, what would be the fastest way to do it? I need to
    get at least 5-10fps. Any help much appreciated.

    Thanks,
    Dan


Working...