Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 699 700 [701] 702 703 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 890123 times)

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10500 on: April 03, 2017, 02:04:28 pm »

Seems I mostly post here to rant, but have any of you ever done any Roku development?

I think the Roku platform could be a case study in bad development platform design.  It may be the worst overall experience I've had purely from a development workflow point of view, including building and debugging software on an embedded DSP.

Not even touching on the fact that the entire app system is built around composing XML and their proprietary and confusingly / poorly documented scripting language BrightScript, it's just very painful to do.  To test apps, you have no emulator.  They're not HTML + JavaScript apps like you'd expect, so you can't test them in a browser.  Your only option is to upload the app to a Roku through a web interface.  That web interface requires a .zip archive of the app.  That means that if you change something, you've got to zip it all up to upload it to test with.  Windows does let you explore ZIP files directly, but you can't edit the files inside directly (or Notepad++ refuses to anyway), so you still have to copy the files into the archive before uploading and testing

At this stage it usually works, but sometimes it freezes and reboots.  If that happens, you have to sit through the reboot process, delete the app from memory because it won't let you "replace" the app if it's identical to the already uploaded version, then upload it again.  Usually works the second time.  Except when it doesn't and you just get a black screen.

I found out after a day of fooling with this that there's a telnet debugger, which is how I discovered that sometimes it doesn't load the app ZIP files correctly.  Some of the archived files are missing.  Deleting and reuploading the exact same file usually works this time.

I've got to be doing something wrong.  I think I read somewhere that here's an Eclipse plugin, and as much as I don't want to install Eclipse for this, maybe it at least handles packaging the ZIP file and sending it to the device.  If I'm super lucky it includes a telnet client for the debugger too.
Logged
Through pain, I find wisdom.

Antsan

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10501 on: April 04, 2017, 02:54:46 am »

I'm trying to write a kind of tonemapping algorithm that enhances local contrast in a given image without sacrificing image clarity. I already wrote a prototype that works quite well, but it's not as flexible as I want it to be and also quite costly in terms of time and space.

The idea is to collect the minimum and maximum intensities in range of a given pixel for multiple given ranges and then calculating the new value for that pixel by computing some value `min` out of the pooled minimum values, `max`out of the pooled maximum values and with original intensity for the pixel `v` via:
Code: [Select]
(v-min)/(max-min)For this I need an efficient pooling algorithm. I currently have this:
:
The idea is to sort pixels by intensity into a list and then write their value into all the relevant pixels in the array holding the pooled values one by one.
First sorting the pixels into a list allows me to write to every pixel only once, but I'm still iterating over the whole rectangle of pixels which might be influenced by a given pixel for every one of those candidates, so basically for a given array with m pixels and a radius of n, time complexity is at O(m*nē). I think it should be possible to avoid iterating over pixels that already have been set, since it should be possible to just avoid the squares that already have been set, which should then make the algorithm O(m) instead, but I don't see how I could keep track of the rectangles already set nor how I could incorporate them into the boundaries for the loop variables.
Can you clarify what you mean by "multiple ranges"? I'm not sure what you mean there exactly, because if you are doing a min/max over any range, the greatest extent will win regardless of range...you might as well just compute over the largest range.  I'm also not quite sure what you mean by "pooled" values - is that the min/max store?  It's also very unclear as to what happens at the corners and edges of the image (since you can't get a meaningful area centered on a pixel in that situation).
Yeah, I'm still trying to figure out how to properly explain what this algorithm does.
I'm doing min/max over multiple fixed ranges and then, for instance, average those values. Or do anything else with them, like doing weighted averages or something like that. This helps with not making darker parts of an image as bright as the bright parts while still enhancing their contrast.
I'm not sure whether min/max-pooling is the same as min/max store. I mean the thing they do in convolutional neural networks in the pooling layers.
At the edges I just ignore all values not on the image. It's the same as assuming pixels outside the image have value +infinity for min/-infinity for max.

Quote
If you are smart about your buffer management, I think you can get down to something that will be closer to O(m*n) for large images, and closer to O(m*n^2) for a small image.  Basically something like
  • For the first (say top-left in this example) pixel in the image, scan the (largest) range (n x n pixels), but scan it by columns each n pixels high.
  • Compute the min/max intensity for that range, then for each column, also store the min/max in that range *without* that column.
  • Scan the next pixel to the right: you now only need to scan n pixels for the new column.
  • Drop the leftmost column, so you have the min/max without it - then you just need to compare the min/max for the new column.
  • Rinse and repeat.
This also avoids the expensive sorting operation.
That sounds good, too. It looks much harder to implement, though, so I'll do it later, when I've got a working prototype.
Logged
Taste my Paci-Fist

Pseudo

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10502 on: April 04, 2017, 10:06:09 pm »

You can reduce that n^2 to n log n by the following:

Suppose your input is this:

Code: [Select]
12343211
11112111
11112223
31111111
71236111
12341111
11211111
11111111

1. Compute a quadtree of maximums.

i.e. level 1 is this:
Code: [Select]
12343211
11112111
11112223
31111111
71236111
12341111
11211111
11111111
[code]
level 2 is this:
[code]
2431
3123
7461
1211
level 3 is this:
Code: [Select]
43
76
level 4 is this:
Code: [Select]
7

This would take O(m log m) time - but you don't need to compute levels above log n, so it's really O(m log n) time. (Specifically, you don't need to compute any level that cannot theoretically fully contain some full pixel + radius.)

2. You can compute the maximum within n distance of a cell by the following recursive "algorithm":

max_total = max(max(all cells at current level that are fully contained within distance of n of the current cell), recurse over all cells at the next level down that are partially contained within distance n of the current cell)

(There's actually a shortcut here - you do not need to recurse on any cells that have a max <= the current max.)

For instance, suppose we want to find the max within distance 3 of cell (4, 4) (1-based) (I'm using Chebyshev distance here as it's simpler for an example)

At level 4 (1,1). The current cell is not entirely within distance 3 of (1) (4,4), so recurse:

At level 3 (1,1) = 4. The current cell is entirely within distance 3 of (1) (4,4), so max >= 4.
At level 3 (2,1) = 3. The current cell is <= 3, but max >= 4, so don't need to recurse.
At level 3 (1,2) = 7. The current cell is not entirely within distance 3 of (1) (4,4), so recurse.
At level 2 (1,3) = 7. The current cell is entirely within distance 3 of (1) (4,4), so max >= 7.
At level 2 (1,4) = 4. The current cell is <= 4, but max >= 7, so don't need to recurse.
At level 2 (2,3) = 1. The current cell is <= 1, but max >= 7, so don't need to recurse.
At level 2 (2,4) = 2. The current cell is <= 2, but max >= 7, so don't need to recurse.
At level 3 (2,2) = 6. The current cell is <= 6, but max >= 7, so don't need to recurse.

max = 7.

Total time per pixel is log(n) - you never recurse on all 4 quadrants of any quad that can fit into the radius. In the case of the Chebyshev metric, you never recurse on all 4 quadrants of a quad of size < 2r, but for euclidean distance it's a little smaller.

However, in practice I suspect this may be substantially slower except for large values of n.

So your overall time is O(m log n), and you can reduce this via parallelism all the way down to O(log n) if you've got enough threads. (Seriously: a GPU would be great for this sort of thing.)

You can actually do something similar for a circular box blur. Though I've never seen anyone implement it - it's not worth it except for very large radiuses, and for very large radiuses box blurs don't look very good.
Logged
The lady the dog the paper the boy writ hit bit knit.

English is weird.

jhxmt

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10503 on: April 07, 2017, 11:42:41 am »

Not programming specifically, but there's no other particularly relevant thread and I feel the need to say (type) this aloud (akey): I am currently in the process of studying for the OSCP certification, with no formal infosec background, and good lord it's fun/frustrating in equal measure.  :D  I haven't gone down this many rabbit holes since I tried to (re)write a MUD engine back when I was in school (more than a decade ago).  I'm learning, but my brain feels like I'm gently tenderising it with a maul.
Logged
Quote from: beefsupreme
Try slaughtering a ton of animals, meat makes less decisions than animals.

Why Your Ramps Don't Work
How To Breach A Volcano Safely

Strife26

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10504 on: April 07, 2017, 07:08:30 pm »

Anyone have any experience with MATLAB? I'm taking a course with it and about to buy the software, but I'm not sure if there's any of the extra modules that are helpful enough to justify another 10 bucks each.
Logged
Even the avatars expire eventually.

McTraveller

  • Bay Watcher
  • This text isn't very personal.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10505 on: April 07, 2017, 08:08:51 pm »

Anyone have any experience with MATLAB? I'm taking a course with it and about to buy the software, but I'm not sure if there's any of the extra modules that are helpful enough to justify another 10 bucks each.
MATLAB is the real evil empire of computing, just nobody notices because it's not consumer-grade and The Mathworks isn't publicly traded.  Those modules you are wondering if they are worth $10?  Once you graduate, add three zeros.  I'm not kidding.

Also, The Mathworks are notorious IP litigants, if you care about such things.

That said, at a minimum: you will absolutely want Simulink, and probably Stateflow.  If you ever want to play around with embedded stuff, you want Matlab Coder (used to be RealTime Workshop). I don't know if Stateflow Coder now is part of Matlab Coder or not.
Logged
This product contains deoxyribonucleic acid which is known to the State of California to cause cancer, reproductive harm, and other health issues.

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10506 on: April 07, 2017, 08:20:11 pm »

Looks like I scored a fulltime C++ job, at last. Local games company, apparently had no luck finding anyone who's any good a C++ (most devs in Melbourne are Unity/C#/Mobile types). These guys do in fact care about bit-twiddling and shaving off a few bytes on data structures to make the memory alignment more efficient and minimize packet size for network gaming. Just finished my first week there, they're devving a racing game, and I had to implement a ghost car / replay system which will also be used for mapping player cars over a network connection.

The weird thing: the lead programmer was born in the same town as me, went to the same primary school I did, and we studied Comp. Sci. at the same university campus, although we've never met before. Which is in another state entirely to where we are now.
« Last Edit: April 07, 2017, 08:22:45 pm by Reelya »
Logged

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #10507 on: April 08, 2017, 05:59:53 am »

That's pretty great, low level optimization seems like your jam :D
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

RoguelikeRazuka

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10508 on: April 08, 2017, 09:10:33 am »

Hello everyone, I need to write a Petri net simulator for Andorid, which allows you to build, trace/debug (that is run step by step) and analyze ordinary Petri nets. A problem is that I have absolutely no experience in making android apps, and the more serious problem is that I have about 1 month of time to do this. What could you suggest? Is it practically viable to learn programming for android and make application of complexity like this in a month? Then, which libraries could I use for making a simple graphical editor for my petri nets android application?
« Last Edit: April 08, 2017, 09:46:37 am by RoguelikeRazuka »
Logged

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #10509 on: April 08, 2017, 09:42:31 am »

as long as you already know how to code, it shouldn't be too hard to make an android app for that.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

TheBiggerFish

  • Bay Watcher
  • Somewhere around here.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10510 on: April 08, 2017, 11:36:11 am »

Hello everyone, I need to write a Petri net simulator for Andorid, which allows you to build, trace/debug (that is run step by step) and analyze ordinary Petri nets. A problem is that I have absolutely no experience in making android apps, and the more serious problem is that I have about 1 month of time to do this. What could you suggest? Is it practically viable to learn programming for android and make application of complexity like this in a month? Then, which libraries could I use for making a simple graphical editor for my petri nets android application?
It's Java-like, so if you know Java or really anything like it, you really shouldn't have problems beyond looking up the documentation.
Logged
Sigtext

It has been determined that Trump is an average unladen swallow travelling northbound at his maximum sustainable speed of -3 Obama-cubits per second in the middle of a class 3 hurricane.

Gatleos

  • Bay Watcher
  • Mournhold... City of Light... City of MAGIC!
    • View Profile
    • Someone Sig This
Re: if self.isCoder(): post() #Programming Thread
« Reply #10511 on: April 08, 2017, 01:42:27 pm »

Spoiler (click to show/hide)
Logged
Think of it like Sim City, except with rival mayors that seek to destroy your citizens by arming legions of homeless people and sending them to attack you.
Quote from: Moonshadow101
it would be funny to see babies spontaneously combust
Gat HQ (Sigtext)
++U+U++ // ,.,.@UUUUUUUU

Arx

  • Bay Watcher
  • Iron within, iron without.
    • View Profile
    • Art!
Re: if self.isCoder(): post() #Programming Thread
« Reply #10512 on: April 09, 2017, 09:59:26 am »

Anyone here had the displeasure of using make with Java? I have to do it for university reasons, but for some bizarre reason compiling my project with

Code: [Select]
JAVAC=/home/arx/jdk1.8.0_121/bin/javac
sources = $(wildcard ./src/*.java)
classes = $(sources:.java=.class ./src/=./bin/)

all: $(classes)

clean :
rm -f *.class

%.class : %.java
$(JAVAC) $<

Gives me 'cannot find symbol' out the wazoo, when it builds just fine in Netbeans. Am I going to have to manually include every class to have them build in the correct order or something? It's kinda inconvenient if so. :P

Edit: Well, I've refined it to "yes" (although the makefile doesn't work for other reasons). Is there a cleaner way of doing this...? I have a lot of classes!
« Last Edit: April 09, 2017, 10:06:38 am by Arx »
Logged

I am on Discord as Arx#2415.
Hail to the mind of man! / Fire in the sky
I've been waiting for you / On this day we die.

TheBiggerFish

  • Bay Watcher
  • Somewhere around here.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #10513 on: April 09, 2017, 10:35:54 am »

Why can't you use Netbeans?
Logged
Sigtext

It has been determined that Trump is an average unladen swallow travelling northbound at his maximum sustainable speed of -3 Obama-cubits per second in the middle of a class 3 hurricane.

Arx

  • Bay Watcher
  • Iron within, iron without.
    • View Profile
    • Art!
Re: if self.isCoder(): post() #Programming Thread
« Reply #10514 on: April 09, 2017, 11:01:16 am »

Quote
university reasons

Finally got it to compile correctly and to the correct folder... but only for specific filenames. Ugh.
Logged

I am on Discord as Arx#2415.
Hail to the mind of man! / Fire in the sky
I've been waiting for you / On this day we die.
Pages: 1 ... 699 700 [701] 702 703 ... 796