473,385 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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(WIDTH, 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(WIDTH, HEIGHT, "\0\0\0\0")

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

rgbframe = yuv.yuv2rgb(WIDTH, 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
Jul 18 '05 #1
0 1406

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: manders2k | last post by:
Hi all -- I'm contemplating the idea of writing a simple emacs-like editor in python (for fun and the experience of doing so). In reading through Craig Finseth's "The Craft of Text Editing": ...
12
by: Martin Dieringer | last post by:
I am trying to split a file by a fixed string. The file is too large to just read it into a string and split this. I could probably use a lexer but there maybe anything more simple? thanks m.
19
by: Lionel B | last post by:
Greetings, I need to read (unformatted text) from stdin up to EOF into a char buffer; of course I cannot allocate my buffer until I know how much text is available, and I do not know how much...
1
by: Vincenzo Conti | last post by:
Hi to all, programming ANSI C on UNIX (Tru64 5.1A, but I hope it is not important). I need to load an executable in memory (ex: a copy of /usr/bin/telnet) and start it from memory. While...
7
by: Michael | last post by:
I'm writing an application that decodes a file containing binary records. Each record is a particular event type. Each record is translated into ASCII and then written to a file. Each file contains...
13
by: George Sakkis | last post by:
I've been trying to track down a memory leak (which I initially attributed erroneously to numpy) and it turns out to be caused by a memory mapped file. It seems that mmap caches without limit the...
2
by: beejisbrigit | last post by:
Hi there, I was wondering if anyone had experience with File I/O in Java vs. C++ using mmap(), and knew if the performance was better in one that the other, or more or less negligible. My...
1
by: James T. Dennis | last post by:
I've been thinking about the Python mmap module quite a bit during the last couple of days. Sadly most of it has just been thinking ... and reading pages from Google searches ... and very little...
1
by: magnus.lycka | last post by:
Does anyone recognize this little Python crasher? I'll file a bug report unless someone notices it as an already documented bug. I found some open mmap bugs, but it wasn't obvious to me that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.