|
Is there a cross platform way to get the rgb value of a specific pixel displayed on screen? The pixel may not be constrained to a certain window, unfortunately. I also need a solution that doesn't rely on dumping screenshots. Language doesn't really matter, but C or Python would be ideal. I also don't really care about OSX, but it would be nice if it worked there too.
|
# ? Oct 11, 2008 04:51 |
|
|
# ? May 13, 2024 23:57 |
|
the talent deficit posted:Is there a cross platform way to get the rgb value of a specific pixel displayed on screen? PyQt (or use the C++ version directly if you have problems with the Python wrapper). Works on Qt, Mac and Linux. I'm not sure what you mean by "dumping screenshots", but I assume you mean you can't save it to an image on disk and then look at the image. The following code will grab the entire screen into a QPixmap in memory and then you get the individual pixel value: code:
|
# ? Oct 11, 2008 05:03 |
|
JoeNotCharles posted:PyQt (or use the C++ version directly if you have problems with the Python wrapper). Works on Qt, Mac and Linux. I'm not sure what you mean by "dumping screenshots", but I assume you mean you can't save it to an image on disk and then look at the image. The following code will grab the entire screen into a QPixmap in memory and then you get the individual pixel value: This is fantastic, thankyou!
|
# ? Oct 11, 2008 05:39 |
I have a set A that contains elements {a, b, e, ff, sf, cd, flol}. I have also the sets B{erf, fds, grh, thj, jju, kkoo, poi, iilh, hjm} C{blah blah blah} D{blah blah blah} and so forth. I need to find which of the other sets contains the largest number of matching elements from A. The elements are not ordered (rather, cannot be ordered because order is meaningless). Is there a name for this kind of problem? I'm really at a loss for anything other than exhaustive search.
|
|
# ? Oct 12, 2008 05:12 |
|
Jo posted:Is there a name for this kind of problem? I'm really at a loss for anything other than exhaustive search. I'd call it a "maximal intersection" problem. Jo posted:The elements are not ordered (rather, cannot be ordered because order is meaningless). You can always impose an ordering on a set (n.b. please do not bring up the axiom of choice). Unless O(n log k) (k being the size of the largest set) is too much, I'd just do the standard sort-intersection, except of course you don't actually need to materialize the intersections. EDIT: I left the algorithm deliberately vague just in case this is a homework assignment. If you need that clarified, I'd be happy to. rjmccall fucked around with this message at 06:33 on Oct 12, 2008 |
# ? Oct 12, 2008 06:21 |
rjmccall posted:You can always impose an ordering on a set (n.b. please do not bring up the axiom of choice). Unless O(n log k) (k being the size of the largest set) is too much, I'd just do the standard sort-intersection, except of course you don't actually need to materialize the intersections. I was hoping to avoid sorting, as the function I have to determine if an object is in a set is featurePoint.equals( fp2 ). equals does a rough evaluation and returns true if the right number of attributes match up. Perhaps sorting is really the only practical way, then. I'll see what I can do to impose some sortable attributes. Thank you much for your advice. EDIT: No, this isn't a homework assignment. I know it sounds like it, but I'm dicking around with an image-search engine. The sets I've been talking about are arrays of feature points from my corner/feature detector. Jo fucked around with this message at 07:06 on Oct 12, 2008 |
|
# ? Oct 12, 2008 06:33 |
|
Jo posted:I was hoping to avoid sorting, as the function I have to determine if an object is in a set is featurePoint.equals( fp2 ). equals does a rough evaluation and returns true if the right number of attributes match up. Ugh, yeah, structures with deep equality semantics are just really difficult to work with. I can't see how you can improve substantially over the brute-force algorithm without further assumptions, though. EDIT: Oh, that sounds cool. Can you explain a little (or even just give me a pointer) about what an image feature is and what it means to evaluate it? Maybe I can help you with an ordering. rjmccall fucked around with this message at 07:16 on Oct 12, 2008 |
# ? Oct 12, 2008 07:11 |
|
I need some help with Regular Expressions. I have a program (Regex Importer for Meedio) that will automatically go through a directory of TV shows and apply regex to the files in order to fill in variable names so they can look up the information online and fill in the missing parts. The only non-standard syntax you need to know to understand the regex below is (?<VariableName>REGEXPATTERN) where essentially anything that matches the REGEXPATTERN will get tossed into the variable. So for example, if you had the following string: "Hello5" and the following regex: (?<Message>[a-zA-Z]*)[0-9] You would end up with the variable Message containing the string "Hello" That having been said, here's my regex: (.*\\)?(?<SeriesName>.*?)(\.|\s)([sS](?<SeasonNumber>[0-9][0-9]?)[^0-9]?[eE](?<EpisodeNumber>[0-9]{2})|(?<SeasonNumber>[0-9][0-9]?)[^0-9]?(?<EpisodeNumber>[0-9]{2}))[^a-zA-Z](\s-\s(?<EpisodeName>)[^\.]*|.*)\.(?<FileType>...) The files I'm trying to match follow the patterns below: Battlestar Galactica Season 3\Battlestar Galactica S03E01 - Occupation.mkv Entourage.501.720p.mkv Entourage.S05E03.720p.09212008.mkv However, for BSG I get no EpisodeName, which makes sense because it's matching the easier .* rather than the more complex pattern that fits BSG. How can I match the BSG episode names without getting crap like "720p" or "720p.02212008" for the other episodes? It's unlikely I'll have more episodes like this, as I ripped these from my DVD collection and renamed them by hand, but since I have the episodes in that format, it'd be nice to have one piece of regex that matches everything. Every Entourage episode comes up with a blank SeasonName, but if I rename the file to "Entourages.S05E03...", then I get "s" as the SeasonName. Edit: I own BSG on DVD, and subscribe to HBO. I have a server with a lot of storage, so I decided to rip/record everything to that and save it because data is ridiculously cheap these days. Fitret fucked around with this message at 19:36 on Oct 12, 2008 |
# ? Oct 12, 2008 18:53 |
|
http://forums.somethingawful.com/showthread.php?threadid=2953970
|
# ? Oct 12, 2008 19:03 |
|
Avenging Dentist posted:http://forums.somethingawful.com/showthread.php?threadid=2953970 I subscribe to HBO and record them with lovely applications that don't let me change the naming structure because I'm too cheap to pay for SageTV or BeyondTV. Plus, these will auto-convert them H264 .mkv's for me. That having been said, I've spent enough time trying to figure out this regex that I might just bite the bullet and buy SageTV or BeyondTV if they'll let me choose how to rename my episodes and automatically compress them. Vista's MediaCenter won't, which is lame. Fitret fucked around with this message at 19:17 on Oct 12, 2008 |
# ? Oct 12, 2008 19:14 |
|
If you told us what DVR application you're using, I bet there's someone here who knows enough about it to tell you how to set it up to use any naming structure you like. Also, I'm not sure why you edited out half of the examples in your post, it's just going to make it harder for anyone to write a working regex for what you need. There's no need to be embarrassed about the shows you watch; we're all friends here.
|
# ? Oct 12, 2008 22:00 |
|
Fitret posted:I subscribe to HBO and record them with lovely applications that don't let me change the naming structure because I'm too cheap to pay for SageTV or BeyondTV. Plus, these will auto-convert them H264 .mkv's for me. That having been said, I've spent enough time trying to figure out this regex that I might just bite the bullet and buy SageTV or BeyondTV if they'll let me choose how to rename my episodes and automatically compress them. Vista's MediaCenter won't, which is lame. Man, I wish I had enough money to afford a dedicated DVR box with enough horsepower to do high-def recording and H264 encoding. I don't get it, though; if you're rich enough to have such a machine, why can't you just buy SageTV or BeyondTV?
|
# ? Oct 12, 2008 22:08 |
|
Avenging Dentist posted:If you told us what DVR application you're using, I bet there's someone here who knows enough about it to tell you how to set it up to use any naming structure you like. Also, I'm not sure why you edited out half of the examples in your post, it's just going to make it harder for anyone to write a working regex for what you need. There's no need to be embarrassed about the shows you watch; we're all friends here. TVEngine3. It's a Meedio plug-in that doesn't work very well. Considering only 1 other goon that I know of uses Meedio, I doubt anyone here has used this software. floWenoL posted:Man, I wish I had enough money to afford a dedicated DVR box with enough horsepower to do high-def recording and H264 encoding. I don't get it, though; if you're rich enough to have such a machine, why can't you just buy SageTV or BeyondTV? The box cost like $600. The H264 encoding is done by my personal PC, not the HTPC. I haven't bought SageTV or BeyondTV because based on what I've read about them, they're not all that great, and if they're not going to be perfect for me, I don't see any reason to buy them when Vista's Media Center is free with the OS. And before you ask why I sprang for the more expensive version instead of getting the cheaper Vista + BeyondTV or SageTV, I work for Microsoft, and Vista Ultimate was like, $50.
|
# ? Oct 13, 2008 06:18 |
|
What exactly is the .bss segement? I get that it's where it stores poo poo as the program is loading, but is it gone after that or what? I noticed it showed up in one of my programs, but doesn't seem to actually take up any physical space. Is this right?
|
# ? Oct 14, 2008 01:17 |
|
slovach posted:What exactly is the .bss segement? I get that it's where it stores poo poo as the program is loading, but is it gone after that or what? It stores static data that should be initialized to zero. Because it's known to contain nothing but zeroes, it's not actually realized in the executeable file - the operating system allocates space for it in RAM and fills that space with zeroes on its own.
|
# ? Oct 14, 2008 01:22 |
|
In PHP I'm trying to take a url that people submit and strip it down a bit. So people can input things like: http://mikemanfrin.com http://www.mikemanfrin.com mikemanfrin.com mikemanfrin.com/blog And I want to make all of these change to: mikemanfrin.com Essentially strip all extra data off the string. I looked at explode, but I couldn't figure out how to account for the different inputs people might have, or how to make sure what they enter is an actual url (ie if someone just typed in 'domain', it should show an error). I'm fairly inexperienced at PHP, so I'm sorry if this is an exceptionally dumb question.
|
# ? Oct 14, 2008 23:19 |
|
http://uk.php.net/function.parse-url Also PHP Thread: http://forums.somethingawful.com/showthread.php?threadid=2802621
|
# ? Oct 14, 2008 23:46 |
rjmccall posted:Ugh, yeah, structures with deep equality semantics are just really difficult to work with. I can't see how you can improve substantially over the brute-force algorithm without further assumptions, though. Feature points contain a lot of information, among the details: Relative x and y coordinates in the image. (I.E. 10% from left, 40% from top) A 5x5 kernel of deltas, detailing how the image changes at that feature point. A tiny histogram (probably going to take this out) of color values. I would sort the feature points by location, but if someone submits a tiny chunk of the image, the feature points aren't going to match up. If the end-user submits a resized photo or a slightly shifted photo, the points will match. Instead, I'm going to have to find some way to sort based on a 5x5 matrix. Again, the problem exists that this matrix might not be matching exactly to the one stored in the database. I'm kinda' stuck here.
|
|
# ? Oct 15, 2008 01:53 |
|
I'm currently working on a computer engineering assignment where I am required to write a small program in Turing that requests 10 integers, then outputs them in reverse order, declaring whether or not each integer is an even or an odd number. Here is my program as of now: code:
|
# ? Oct 15, 2008 07:43 |
|
(Apologies in advance for pedanticism.) I'm not too familiar with Turing, but it seems that it has an 'if [true|false] then statement1 else statement2" construct. With that, you can do the splitting. Now all you need is a way to find out whether the number is even ('true' or 'false'). You know that even numbers are of the form 2m, and odd numbers are of the form 2m+1. What happens in Turing if you divide an integer by another integer? For example, what does Turing think 3/2 is? I'm betting it is 1, although 2 is possible also. It is highly unlikely that it returns the "real" answer of 1.5 due to the types of the inputs (integers); we wouldn't be able to do something simple like x = (x/2)! So, if p/2 yields a value m, then 2m should be p. (Why might they not be the same?) Well, if 3/2 gives us 1, and 1*2=2, we notice that 2 isn't equal to 3. Hmmm...
|
# ? Oct 15, 2008 08:02 |
|
I just tried 3/2, the output was 1.5. I then triedcode:
|
# ? Oct 15, 2008 08:08 |
|
Assberging posted:I just tried 3/2, the output was 1.5. I then tried % Perhaps?
|
# ? Oct 15, 2008 08:16 |
|
It's "mod" As in foo := bar mod 2 Also, I want you to go to school and call your teacher a stupid fag because seriously Turing is basically just a crappy version of Pascal.
|
# ? Oct 15, 2008 08:24 |
|
Avenging Dentist posted:It's "mod" Got it! Thanks
|
# ? Oct 15, 2008 08:57 |
|
Oops. Sorry about that. (Turing really does that? Wow. That's pretty dumb.)
|
# ? Oct 15, 2008 16:40 |
|
oops didnt read the OP
Ru fucked around with this message at 15:03 on Oct 16, 2008 |
# ? Oct 16, 2008 15:00 |
|
In C:quote:char c = 148; Rather than outputting 148, it gives me -108. On closer inspection, I seem to be getting incorrect values when an ASCII character's integer value is => 100. Is something wrong with my libraries, or am I retarded/missing something? EDIT: Whoops, probably should've posted this in the C/C++ thread. citsejam fucked around with this message at 02:23 on Oct 18, 2008 |
# ? Oct 18, 2008 02:15 |
|
citsejam posted:Rather than outputting 148, it gives me -108. On closer inspection, I seem to be getting incorrect values when an ASCII character's integer value is => 100. Is something wrong with my libraries, or am I retarded/missing something? Pretty much that. You're outputting an unsigned value with a signed flag. Signed chars range from -128 to 127. Use %u
|
# ? Oct 18, 2008 02:24 |
|
Avenging Dentist posted:Pretty much that. You're outputting an unsigned value with a signed flag. Signed chars range from -128 to 127. Use %u Using %u instead spits out 4294967188 .
|
# ? Oct 18, 2008 02:30 |
|
Well first of all you should be using an unsigned char if you actually care about values >127. Also, printf casts everything up to an int (*) when you call it. * Lies
|
# ? Oct 18, 2008 02:36 |
|
Thanks. Making the characters unsigned did the trick.
|
# ? Oct 18, 2008 02:53 |
|
Dumb question. What is the difference between a Perl regular expression and a regular expression? I tried Googling, but the only interesting thing I found is that two regular expression matching engines can differ based upon their matching technique, backtracking or DFA (interesting but not pertinent). Comment by Bill McCloskey on http://blog.mozilla.com/dmandelin/2008/10/06/squirrelfishing-in-regexp-dnajs/ posted:the backtracking approach doesn’t use longest-match semantics as the NFA approach does. So the two techniques differ in more than their performance properties. Here’s an example, written in Python: What I'm looking for are examples of how a (Ruby|Java|.NET) regex might match differently in Perl, and why? I did find ECMAScript 3 Regular Expressions are Defective by Design, but that looks like a special case. My basic question is: is there a portable syntax for (a subset of) regexes?
|
# ? Oct 21, 2008 01:44 |
|
Nearly every language uses Perl Compatible Regular Expressions. There isn't really a whole lot out there that just uses POSIX regexes.
|
# ? Oct 21, 2008 02:11 |
|
POSIX defines both basic (used by grep) and extended (used by egrep) regular expressions (you can check regex(3) for the functions and regex(7) for more info, but the web is your best bet for these). As you would guess, POSIX regexes are portable to anything nixy. Perl-compatible regular expressions, on the other hand, are the de facto standard for modern languages, and are your best bet for cross-platform portability. A (huge) guide to regex compatability (in terms of whether things are implemented, differences are even harder to track 'well') between languages and frameworks can be found at http://www.regular-expressions.info/refflavors.html (scroll down a little for megatable).
|
# ? Oct 21, 2008 02:34 |
|
Z-Bo posted:What is the difference between a Perl regular expression and a regular expression? I tried Googling, but the only interesting thing I found is that two regular expression matching engines can differ based upon their matching technique, backtracking or DFA (interesting but not pertinent).
|
# ? Oct 21, 2008 09:16 |
|
Also the escaping rules for non-perl regexes are going to drive you mad.
|
# ? Oct 21, 2008 21:15 |
|
Vanadium posted:Also the escaping rules for non-perl regexes are going to drive you mad. Oh lord yes. And the ability to capture substrings is severely limited and problematic in posix regex compared to perl compatible RE, as I learned recently.
|
# ? Oct 22, 2008 09:50 |
|
In C can you somehow compare two FILE * to see if they are pointing at the same file? I don't care about compatibility with symlinks or whatever, these will be two FILE * pointing to potentially one regular file on the hard drive.
|
# ? Oct 24, 2008 21:18 |
|
Ugg boots posted:In C can you somehow compare two FILE * to see if they are pointing at the same file? I don't care about compatibility with symlinks or whatever, these will be two FILE * pointing to potentially one regular file on the hard drive. EDIT: vvv You can do that, but it's platform specific and non-standard. TSDK fucked around with this message at 21:39 on Oct 24, 2008 |
# ? Oct 24, 2008 21:25 |
|
|
# ? May 13, 2024 23:57 |
|
Ugg boots posted:In C can you somehow compare two FILE * to see if they are pointing at the same file? I don't care about compatibility with symlinks or whatever, these will be two FILE * pointing to potentially one regular file on the hard drive. Untested, but this should work. I don't know if there's a shorter way; this is just the first solution that I thought of. code:
|
# ? Oct 24, 2008 21:27 |