Page 1 of 2 12 LastLast
Results 1 to 15 of 19

Thread: running the CPU and GPU on a Raspberry pi.(Searching..) and I ran across this.

  1. #1

    running the CPU and GPU on a Raspberry pi.(Searching..) and I ran across this.

    In the spirit of leaving a trail of breadcrumbs through the forest, I�m going to run through some of what I learned along the way.

    http://petewarden.com/2014/08/07/how-to-optimize-raspberry-pi-code-using-its-gpu/

    Excellent article and has links to even more interesting documentation for the pi.

    As a side note or tip for running mono C# code on raspberry pi.
    Code:
            static Object FileLock = new Object();
            static void Main()
            {
    	        //Get the Directory This is executing from example "WorkFolder\XmlData\..."
    	        System.IO.DirectoryInfo workingDirectory = new System.IO.DirectoryInfo(System.IO.Directory.GetCurrentDirectory());
    	        //## requirement of being in the directory where the xml files to be parsed are.##
    	        //read all the ProductData*.xml files in the current directory
    	        System.IO.FileInfo[] xmlFiles = workingDirectory.GetFiles("ProductData*.xml");
    	        //Create A thread Array equal to the number of files to parse
    	        //Create a thread for each file found to parse in parallel
    	        for (int i = 0; i < xmlFiles.Length - 1; i++) {
    		        System.Threading.Thread T = new System.Threading.Thread(() => thread_parser(xmlFiles[i].FullName));
    		        T.Start();
                }
            }
    This will not work if the number of files and there sizes exceeds the memory Threshold of the device.
    There are a few ways to accomplish this.
    Use a global counter and to only allow a certain number of threads to be running in the code.
    Remove the threading part all together and go for a function loop on thread_parser.
    Implement a lock in thread_parser to only allow 1 thread.

  2. #2
    Teach, Not Flame Kayaker's Avatar
    Join Date
    Oct 2000
    Posts
    4,146
    Blog Entries
    5
    Still reversing that esoteric stuff huh? Good on ya, keep it up
    Sorry, we still haven't banned you after all these years

  3. #3
    Nah, just got a pi for Christmas and jumped into what I thought was interesting in the community and wanted to see if I could write code to run on the GPU of the pi.

    The code is the head of the implementation to parse GS1 1worldsync product data from manufacturers into NCR Power Menu for a distributor.(boring shit right there..)

    Towards the last comment:
    Self made shackles work best for me, breaking out of them is really hard and time consuming unlike anything you or others could have done to me.

    This is supposed to be off-topic so I should have avoided your question and just rambled on..

  4. #4
    I dont see any way I could ban him.

    Anyway, interesting stuff regarding pi.

    Woodmann
    Learn Or Die.

  5. #5

    Post GPGPU with WebGL

    https://www.khronos.org/opengles/sdk/docs/reference_cards/OpenGL-ES-2_0-Reference-card.pdf
    https://www.khronos.org/opengles/2_X/

    http://nullprogram.com/ more in depth usage examples
    https://news.ycombinator.com/item?id=1460065
    http://learningwebgl.com/blog/?p=1828


    Enjoy the reading, any further information or usage experimentation notes would be greatly appreciated if a link was posted here.

  6. #6

    Embedding ascii to a image to make image that is self documenting.

    So taking a idea from stenography and encoding 1 picture inside another using the least significant byte of a pixels RGB...So this is all well and good when combining 2 images, but what if I don't want to embed a image into another image. what if I want to embed Ascii into a image. I suppose the same method would work, read a the image data for RGBA, find the least significant byte and overwrite it with desired code for 1 value. But what if we don't care who see's my modifications to the image, this opens up RGB for storage in the full scale. To accomplish this I take image and load it into a canvas with image.width - 2 and image.height -2 to allow for a 1 pixel border region for data. I then directly associated ascii keycodes to color codes and write the desired text to the image. 1 of the most annoying things I ran across while implementing this functionality was CORS(cross origin resource sharing policy) and SORS(Same origin resource sharing Policy) which describe a set of permissions for editing and modifying content downloaded from the web.It seems chrome chokes on this much more then even IE, firefox or opera.

    The next stage of this is taking the 2d data fragments and storing them into a 3D cylinders inner surface with multiple viewpoints set onto a line that runs up the middle of the cylinder. IE each viewpoint has a range of accessible data located next to that view point to which I can send a query to retrieve the data in question via reducing the overall space the query has to look through.

  7. #7
    Teach, Not Flame Kayaker's Avatar
    Join Date
    Oct 2000
    Posts
    4,146
    Blog Entries
    5
    If you're into transmogrifying files, you might be interested or already seen some of these examples of binary polyglots.

    https://code.google.com/p/corkami/ (under Binary Files)

    A few of the polyglots are actual issues of the International Journal of Proof-of-Concept or Get The Fuck Out (PoC||GTFO)
    (google 'pocgtfo' for some analysis of how to manipulate the file contents)

    Issue 03 is, at the same time, several file formats: PDF/ZIP/JPG/Audio (raw AFSK)/PNG (encrypted with AES)
    Issue 04: TrueCrypt, PDF , ZIP polyglots
    Issue 05: Flash, Iso, PDF, ZIP polyglots

    Pretty amazing stuff. I found that Foxit might open the pdf format if Adobe doesn't, and 7-zip or or 'nix unzip could handle it when the extension is changed to .zip.

    Would be interested in seeing your ascii-in-jpg if you get a poc.

    K.

  8. #8
    Code is written in Javascript, and I have posted it to codereview.stackexchange.com a few times to get idea's on improvements for my code.

    Code:
     <!DOCTYPE html>
    <html>
    <body>
    
    <canvas id="myCanvas" width="200" height="200" style="border:1px solid #d3d3d3;">
    Your browser does not support the HTML5 canvas tag.</canvas>
    <p id="Start"></p>
    <p id="End"></p>
    <div id="img_store" style="display:none"></div>
    <textarea id="WriteThis"></textarea>
    <button onclick="loadImageAndWrite('download.png');">Load Image and Write Text</button>
    <script>
    var ColorizeData = function(canvas) {
    	this.canvas = canvas;
    	this.charToDecTable = {};
    	this.decToCharTable = {};
    }
    ColorizeData.prototype.initTables = function(){
    	var charDecPairs = [
    		["	","09"],
    		["\r","16"],
    		["\n","19"],
    		[" ","32"],
    		["!","33"],
    		['"',"34"],
    		["#","35"],
    		["$","36"],
    		["%","37"],
    		["&","38"],
    		["'","39"],
    		["(","40"],
    		[")","41"],
    		["*","42"],
    		["+","43"],
    		[",","44"],
    		["-","45"],
    		[".","46"],
    		["/","47"],
    		["0","48"],
    		["1","49"],
    		["2","50"],
    		["3","51"],
    		["4","52"],
    		["5","53"],
    		["6","54"],
    		["7","55"],
    		["8","56"],
    		["9","57"],
    		[":","58"],
    		[";","59"],
    		["<","60"],
    		["=","61"],
    		[">","62"],
    		["?","63"],
    		["@","64"],
    		["A","65"],
    		["B","66"],
    		["C","67"],
    		["D","68"],
    		["E","69"],
    		["F","70"],
    		["G","71"],
    		["H","72"],
    		["I","73"],
    		["J","74"],
    		["K","75"],
    		["L","76"],
    		["M","77"],
    		["N","78"],
    		["O","79"],
    		["P","80"],
    		["Q","81"],
    		["R","82"],
    		["S","83"],
    		["T","84"],
    		["U","85"],
    		["V","86"],
    		["W","87"],
    		["X","88"],
    		["Y","89"],
    		["Z","90"],
    		["[","91"],
    		["\\","92"],
    		["]","93"],
    		["^","94"],
    		["_","95"],
    		["`","96"],
    		["a","97"],
    		["b","98"],
    		["c","99"],
    		["d","100"],
    		["e","101"],
    		["f","102"],
    		["g","103"],
    		["h","104"],
    		["i","105"],
    		["j","106"],
    		["k","107"],
    		["l","108"],
    		["m","109"],
    		["n","110"],
    		["o","111"],
    		["p","112"],
    		["q","113"],
    		["r","114"],
    		["s","115"],
    		["t","116"],
    		["u","117"],
    		["v","118"],
    		["w","119"],
    		["x","120"],
    		["y","121"],
    		["z","122"],
    		["{","123"],
    		["|","124"],
    		["}","125"],
    		["~","126"],
    		["","127"]
    
    
    	];
    	for(i=0; i < charDecPairs.length; i++)
    	{
        		var pair = charDecPairs[i];
        		var cchar = pair[0];
        		var dec = pair[1];
        		this.charToDecTable[cchar] = dec;
        		this.decToCharTable[hex] = cchar;
    	}
    }
    ColorizeData.prototype.textToColor = function(arg){
        var context = this.canvas.getContext("2d");
        var upDown = 1;
        var upDown1 = 1;
        var leftRight = 0;
        var cindex = 0;
        arg = arg.toLowerCase();
        do
        {
    	if(cindex + 1 < arg.length)
    	{
    		if(cindex + 2 < arg.length)
    		{
    			context.fillStyle = rgbToHex(this.charToDecTable[arg.charAt(cindex)],this.charToDecTable[arg.charAt(cindex+1)],this.charToDecTable[arg.charAt(cindex+2)]);
    			cindex += 3;
    		}
    		else
    		{
    			context.fillStyle = rgbToHex(this.charToDecTable[prop], this.charToDecTable[arg.charAt(cindex+1)],0);
    			cindex += 2;
    		}
    	}
    	else
    	{
    		context.fillStyle = rgbToHex(this.charToDecTable[prop],0, 0);
    		cindex +=1;
    	}
    	if(context.fillStyle != "#000000")
    	{
    		
            	if(cindex/3 < this.canvas.width) {
            	    context.fillRect(leftRight, 0, 1, 1);
            	    leftRight += 1;
            	}
            	else
            	{   
            	    if(upDown < this.canvas.height) {
            	        context.fillRect(leftRight,upDown,1,1);
            	        upDown += 1;
            	    }
            	    else
            	    {
            	        if(upDown1 < this.canvas.height) {
            	            leftRight = 0
            	            context.fillRect(leftRight,upDown1,1,1);
            	            upDown1 +=1
            	        }
            	        else
            	        {
            	            if(leftRight < this.canvas.width -2) {
            	                leftRight+= 1;
            	                context.fillRect(leftRight,upDown1-1,1,1);
    		            }
    		        }
    		    }
    		}
    	}	
        }while(cindex < arg.length)
    }
    function componentToHex(c) {
    	var hex = Number(c).toString(16);
    	return hex.length == 1 ? "0" + hex : hex;
    }
    function rgbToHex(r, g, b) {
    	return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
    }
    ColorizeData.prototype.colorToText = function(arg) 
    {
    	var text = "";
    	var context = this.canvas.getContext("2d");
    	var size = 0;
    	for(var index = 0;index<4;index++)
    	{
    		switch (index)
    		{
    			case 0:
    				imgData = context.getImageData(0,0, this.canvas.width,1);
    				size = this.canvas.width;
    				break;
    			case 1:
    				imgData = context.getImageData(this.canvas.width - 1,1, 1,this.canvas.height - 1);
    				size = this.canvas.height - 1;
    				break;
    			case 2:
    				imgData = context.getImageData(0,1, 1,this.canvas.height - 1);
    				size = this.canvas.height - 1;
    				break;
    			default:
    				imgData = context.getImageData(1,this.canvas.height -1, this.canvas.width-2, 1);
            			size = this.canvas.width - 2;
    		}
    		for(var i = 0; i < size; i += 4) {
    			//hide this pixel.
    			imgData.data[i + 3] = 0;
    			//check red for 0
    			if(imgData.data[i + 0] != 0)
    			{
    				text += this.decToCharTable[imgData.data[i + 0]];
    			}
    			else
    			{
    				break;
    			}
    			//check green for 0
    			if(imgData.data[i + 1] != 0)
    			{
    				text += this.decToCharTable[imgData.data[i + 1]];
    			}
    			else
    			{
    				break;
    			}
    			//check blue for 0
    			if(imgData.data[i + 2] != 0)
    			{
    				text += this.decToCharTable[imgData.data[i + 2]];
    			}
    			else
    			{
    				break;
    			}
    
    		}
    		switch(index)
    		{
    			case 0:
    				context.putImageData(imgData,0,0);
    				break;
    			case 1:
    				context.putImageData(imgData,this.canvas.width - 1,1);
    				break;
    			case 2:
    				context.putImageData(imgData,0,1);
    				break;
    			case 3:
    				context.putImageData(imgData,1,this.canvas.height -1);
    				break;
    			default:
    				alert("fail");
    		}
    	}
    	document.getElementById(arg).innerText = text;
    }
    ColorizeData.prototype.loadImage = function(arg) {
    	var canvas = document.getElementById("myCanvas");
    	var context = canvas.getContext("2d");
    	var img = new Image();
    	img.onload = function () {
    	    context.drawImage(img, 0, 0, 200, 200);
    	};
    	img.src = arg;
    }
    ColorizeData.prototype.loadImageAndRead = function(arg) {
    	var canvas = document.getElementById("myCanvas");
    	var context = canvas.getContext("2d");
    	var img = new Image();
    	img.onload = function () {
    	    context.drawImage(img, 0, 0, 200, 200);
    	    Colorizer.colorToText('Start');
    	};
    	img.src = arg;
    }
    ColorizeData.prototype.loadImageAndWrite = function(arg) {
    	var canvas = document.getElementById("myCanvas");
    	var context = canvas.getContext("2d");
    	var img = new Image();
    	img.onload = function () {
    	    context.drawImage(img, 0, 0, 200, 200);
    	    Colorizer.textToColor(document.getElementById("WriteThis").value);
    	};
    	img.src = arg;
    }
    
    ColorizeData.prototype.clear = function() {
    	var context = this.canvas.getContext("2d");
    	context.clearRect(0,0,this.canvas.width, this.canvas.height);
    }
    var Colorizer = new ColorizeData(document.getElementById("myCanvas"));
    Colorizer.initTables();
    Colorizer.textToColor("Testing 123...");
    
    </script>
    </body>
    </html>
    Example of (1st) generation image is attached. This code is 3rd generation, translation tables changed so it wont work for this image.
    1st generation code is here.
    http://codereview.stackexchange.com/questions/77746/converting-text-to-colored-pixels-and-back-again

    Thanks for all the decent reading material.
    Attached Images Attached Images  
    Last edited by BanMe_2; February 3rd, 2015 at 10:53. Reason: thirds.

  9. #9
    I want to learn, even while I am dying.

    http://stackoverflow.com/questions/28441774/i-need-help-implementing-this-algorithm-for-the-1worldsync-dam-api
    Last edited by BanMe_2; February 10th, 2015 at 16:12.

  10. #10
    I have more than the arts in mind kayaker.

    I plan to use this concept to reduce http traffic on the web, by embedding content into images and have the client parse the images with javascript.

    (Re)think my idea's please.
    Last edited by BanMe_2; December 30th, 2015 at 18:09.
    What is old will become new again.

  11. #11
    Super Moderator
    Join Date
    Dec 2004
    Posts
    1,525
    Blog Entries
    15
    BanMe_2

    I want to learn, even while I am dying.

    http://stackoverflow.com/questions/28441774/i-need-help-implementing-this-algorithm-for-the-1worldsync-dam-api
    are you still stuck on the damapi ??
    iirc you opened another thread here on the same damapi
    if you are struck use this powershell script

    i don't know if it works with your data or not in the link but it works with the damapi pdf example correctly

    Code:
    $a = New-Object System.Security.Cryptography.HMACSHA256
    $a.key = [Text.Encoding]::ASCII.GetBytes($args[1])
    [Convert]::ToBase64String($a.ComputeHash([Text.Encoding]::ASCII.GetBytes($args[0])))
    run as

    Code:
    :\>powershell -f hmack.ps1 "/V2/assets?app_id=12345& ipGLN=1234567891234&senderGLN=1234567891234&TIMESTAMP=2012-12-06T13:08:02Z" 6
    b904a0c5ceefa991b2ebc9cfec202b6
    xCimvrWfNZ3o83wugChCU0oaaaP9vIfztHi9TMhgoYA=
    the input and output can be verified from page 36 of the damapi.pdf (retrieved around the date of the other damapi thread)

  12. #12
    That's a pretty small implementation. But I finished it all. got it all working synchronously and then there like ok use it to upload 20k images.. it was to slow so I looked into speed it up with asynchronous tasks and was unable to get it to work properly so I reverted to type and wrote a html page with a javascript multi drop file handler for image files, made the load code wrap in a xml file with some predefined variables, zipped them up and sent them on as2 connection. :] But thank you for the effort good citizen. I appreciate it.

    On a side note I have been thinking about something, that you might be able to help me with, has to do with javascript.

    But I was wondering, if an idea I had was feasible, from my laymen perspective could 2 RGBA webgl pixels be combined to form a register?Could we define 0 as black or white and perform shader operations on the set color values? I mean couldn't we colorize a pair of RGBA 4 bytes each into a qword length buffer and store data in registers, and compare how far away from black or white it is to determine the value of it. The pixel paired registers could then be used to process instructions from some source.
    I should patent the ideas I have, but I choose to just give them to the winds...
    Last edited by BanMe_2; December 29th, 2015 at 11:39. Reason: fixed for accuracy and completed train of thought.
    What is old will become new again.

  13. #13
    Super Moderator
    Join Date
    Dec 2004
    Posts
    1,525
    Blog Entries
    15
    well to be frank i have no idea my JavaScript know-how is very limited
    just because i wanted to get into my head something before i can make a half or quarter sensisible reply i followed into the
    link (first generation thingy) a brief glance tell me you want to make some thing like this


    Code:
    Add-Type -AssemblyName *sys*forms*
    Add-Type -AssemblyName System.Drawing
    $fg=($f=New-Object Windows.Forms.Form).createGraphics()
    $f.Width=350;$f.Height=70;$f.Text="Banme Games" 
    $table=@{
    "a"="#000020";"b"="#000040";"c"="#000060";"d"="#000080";"e"="#0000a0";"f"="#0000c0";
    "g"="#0000e0";"h"="#001010";"i"="#002030";"j"="#003050";"k"="#004070";"l"="#005090";
    "m"="#0060b0";"n"="#0070d0";"o"="#0080f0";"p"="#009020";"q"="#00a040";"r"="#00b060";
    "s"="#00c080";"t"="#00d0a0";"u"="#00e0c0";"v"="#00f0e0";"w"="#102010";"x"="#204030";
    "y"="#306050";"z"="#408070";" "="#50a090";"-"="#60c0b0";"="="#70e0d0";"0"="#800000";
    "1"="#801000";"2"="#802000";"3"="#803000";"4"="#804000";"5"="#805000";"6"="#806000";
    "7"="#807000";"8"="#808000";"9"="#809000";"@"="#000000";"!"="#000000";
    };
    $in = "hello ban me @ 42 d0wnning greet!";Name:  banme.PNG
    Views: 189
    Size:  6.4 KB
    $i = $j = $k = 0;
    $p = @(0..50);
    $in.ToCharArray() | %{ 
    $p[$j++] = New-Object Drawing.Solidbrush ($table.Item($_.tostring()))
    $f.add_paint({$fg.FillRectangle($p[$k++],($i+=10),10,5,10)})
    } $f.ShowDialog() > null

  14. #14
    Excellent stuff this what looks to be javascript, but probably is powershell.. excellently small. but no, I meant in a canvas with a pixel and a fragment shader.

    This link might help in clarifying, what I am talking about.

    http://nullprogram.com/blog/2014/06/10/

    I also heard about storing data in images even if they are resized? Is there further reading material for this as well? I need to be less of a librarian or something.. sorry.

    Also greetz to you blabberer, much respect for the truths.

    001010 0000a0 005090 005090 0080f0 50a090 000040 801000 000020 000040 00004 0000a0 00b060 0000a0 00b060.

    and yes blabber png is the extension I misspoke before.but it doesn't matter, because you don't need to load and render the image on the canvas, because the canvas is the image. That's some "there is no spoon" shit right there if I ever saw it..
    Last edited by BanMe_2; December 29th, 2015 at 12:15.
    What is old will become new again.

  15. #15

    Capturing a exe file in color and symbolically executing the colored representation.

    That is what I want to do, and I would like to do that in the gpu's renderings.So Not Image processing,processing in a image, emulated but realtime rendered. executing the input and giving a output instruction by instruction on something in that image and 'could' be rendered in a web page.

    scrape a concept™ from UNU project

    Maybe the question you ask yourself, is why the fuck does this bloke want to do any of this, what is his end goal, I have no fucking idea, but I do try and explore things and ideas differently because I wish to have my own. Even if it is coupling the many disparate and unrelated fields of my interests together.
    Last edited by BanMe_2; December 29th, 2015 at 11:55.
    What is old will become new again.

Similar Threads

  1. Searching commands
    By Bilal in forum OllyDbg Support Forums
    Replies: 4
    Last Post: July 17th, 2004, 03:02
  2. Searching Games
    By Woodmann in forum The Newbie Forum
    Replies: 15
    Last Post: June 5th, 2003, 17:59
  3. Searching for SentinelLM 7.0 SDK
    By Sope in forum Tools of Our Trade (TOT) Messageboard
    Replies: 0
    Last Post: July 13th, 2001, 13:22
  4. Searching for breakpoint(s)
    By bobik in forum Malware Analysis and Unpacking Forum
    Replies: 1
    Last Post: July 5th, 2001, 01:27
  5. Searching 4 ??
    By Critter in forum Malware Analysis and Unpacking Forum
    Replies: 2
    Last Post: March 12th, 2001, 09:47

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •