World: r4wp
[#Red] Red language group
older newer | first last |
Bo 2-Jul-2013 [9231x2] | I'll just use write/append/binary with #{0A} as the terminator. |
It's working now. Thanks for all your detective work! I don't know how you can find bugs so fast. | |
Kaj 2-Jul-2013 [9233] | I didn't think it was very fast. :-) I had a hunch in the direction of corrupted printing all the time, but didn't think of CR |
Bo 2-Jul-2013 [9234] | What I meant was "fast compared to me." |
Kaj 2-Jul-2013 [9235x3] | :-) |
It still sucks to loose hours to this issue fourty years after it was perpetrated | |
I suppose it would be useful if I made read-file more like REBOL, like it already behaves on Windows. I'll look into that tomorrow | |
Bo 2-Jul-2013 [9238] | You're awesome! |
Kaj 2-Jul-2013 [9239] | Thanks |
Bo 2-Jul-2013 [9240] | For anyone interested, I just published a JPG in the Files section under Misc called MotionDetect.jpg showing real-time motion detection performed by the Raspberry Pi running Red/System. The top two frames are the actual camera video (shot at dusk) and the bottom frame highlights the areas of motion. Thanks in huge part goes to Kaj for helping me finish this first project! |
Kaj 2-Jul-2013 [9241] | Cool to see it displayed like that |
Bo 2-Jul-2013 [9242x2] | What do you mean by "displayed like that"? |
By the way, the bottom image is completely built by Red/System. | |
Kaj 2-Jul-2013 [9244] | Well, displayed at all. :-) So far I had only seen isolated code snippets |
Bo 2-Jul-2013 [9245x2] | Have to protect my intellectual property. :-P |
I really can't thank you enough, Kaj, for all your help! | |
Kaj 2-Jul-2013 [9247] | Yes, but that's not what I mean. It's all very abstract and seems like any other code, but now it comes to life |
Bo 2-Jul-2013 [9248x2] | I love the feeling that I get when I see my software working! Especially something I've been struggling with for days/weeks/months. |
My original prototype written in R2 was started 3-Aug-2012 and finished 9-Sep-2012. It's taken this long to get it running on the Pi natively. | |
Kaj 2-Jul-2013 [9250] | Was that fast enough? |
Bo 2-Jul-2013 [9251] | The development cycle? Or the speed of the software? |
Kaj 2-Jul-2013 [9252] | R2 |
Bo 2-Jul-2013 [9253x3] | R2 couldn't do it nearly fast enough on the Pi. |
However, it was fast enough on a powerful workstation. | |
R2 could even handle several cameras simultaneously on a powerful workstation (maybe 4 cameras at 1.3 megapixels @ 8fps). | |
Kaj 2-Jul-2013 [9256] | Not bad, but not available on ARM |
Bo 2-Jul-2013 [9257] | Right. |
Kaj 2-Jul-2013 [9258] | So can you do without the Broadcom specs now? |
Bo 2-Jul-2013 [9259x2] | I've found a way around it for now, but I've had to make some concessions that I'm not very happy with. My goal is to still get my hands on those Broadcom specs so I can get better performance and flexibility. |
My motion detection executable on the Pi is 30KB. The same executable compiled for Windows is 15KB (50% the size). | |
Kaj 2-Jul-2013 [9261] | Yes, the ARM instruction set is optimised for speed at the expense of size |
Bo 2-Jul-2013 [9262x3] | I've got plenty of room on the Pi, but not a lot of processing power. |
So I'm thankful for that. | |
Another thing I've never tried in Red/System and can't seem to get to work: min-pixel-area-text: make-c-string 16 min-pixel-area-text: read-file "config/motion-trigger-min-pixel-area.txt" print-line ["Minimum Pixel Area = " min-pixel-area-text] min-pixel-area: as-integer min-pixel-area-text print-line ["Minimum Pixel Area = " min-pixel-area] Output: Minimum Pixel Area = 1 Minimum Pixel Area = 3358672 | |
XieQ 2-Jul-2013 [9265] | @Bo 'read-file' will call 'fread' in libc, so it will return the total amount of bytes read. I think 'Minimum Pixel Area = 3358672' is the number of bytes read from your file, but I have no idea why it print a '1' in the first output. |
Bo 2-Jul-2013 [9266] | Thanks for the suggestion. I had the number "40" in the file before, and it printed "40", but gave me the same long number in the second 'print-line. So I don't think that is it. |
Pekr 3-Jul-2013 [9267x2] | I am with Arnold here, but I admit that it might be a psychological aspect, nothing more. Simply put - we have some low level stuff available, and I fear bulding higher (Rebol level) commands will be waste of time, as Doc will most probably rewrite it differently? |
Let's take e.g. 'read function. Where will it be created? Red/System level? Red level? Both? E.g. Red/System does not allow refinements, so I expect some "natives" code will be done using R/S, and higher abstraction via routines in Red level? | |
DocKimbel 3-Jul-2013 [9269] | Bo, congrats! Hope you'll demo it at the devcon. |
Pekr 3-Jul-2013 [9270] | btw - my brother ordered 3x Arduino kit for our friends, and for me he ordered BeagleBone Black. So I will see, if I can get Red programs running on it :-) |
DocKimbel 3-Jul-2013 [9271x2] | Red should run just fine on the BB Black. |
My motion detection executable on the Pi is 30KB. The same executable compiled for Windows is 15KB (50% the size). Red currently emits only the standard ARM opcodes, so 32-bit per instruction. We'll add support in the future for Thumb mode (more compact instruction set). In the meantime, you can try to activate the literal pools by adding the following option to the Linux-ARM config block (in %config.r): literal-pool?: yes That should both reduce final binary size and give you a little speed improvement. But be sure to test is well as this mode has not been much used yet. Also, it might fail to compile if you use very big functions, or a lot of code in global context. | |
Kaj 3-Jul-2013 [9273x8] | Bo, your make-c-string leaks memory. read-file will allocate memory of the size to fit the file contents |
Xie, read-file is a Red/System function that does much more than fread. It returns the file content itself as a string, not the number of bytes read | |
fread is mapped directly to read-array | |
Bo, your file must contain "1". The second number is the address where it is read into memory | |
Remember that a c-string! is a pointer to a memory address. Much like a string! in REBOL is a reference to the storage of a series value that can be referenced by multiple string!s, each with their own index | |
If you want to convert the content of your text file to an integer, my C library binding provides to-integer, just like in REBOL | |
Petr, the Red/System READ functions and the higher Red abstractions on top of it are already here. As I said yesterday, Doc is free to use parts of it when he makes a more elaborate I/O framework in Red | |
You're not wasting any time on them, are you (except by talking about them)? I need them now, and so do others | |
older newer | first last |