I'm currently creating an application that requires me to refer to coordinates such as (1000,1500) on a bitmap image that is only (100,100), so I have thought of using y = 1000 as the origin instead of 0 and y = 2000 instead of 100, I have looked at lots of articles and questions on different websites but have not come across a way of doing so. I apologise for not being able to show any code that I have done right now but I'm wondering if anybody has any ideas on how to go about doing this.
Thank you for reading :)
It sounds like the easiest way to do this would just be to resize the bitmap. I'm not really sure what you're talking about with the origin thing, but it would be easy to make the bitmap 1500 x 1500 instead of 100 x 100. If that isn't an option, please explain what you are trying to use to make the application
Related
I would like to know if there is a way to align the RGB picture and the depth data of a Kinect V2 using the colour data as a starting point using Java, I am actually using java for Kinect as a wrapper and it does not seem to give me the possibility for that. Is there any way doing that?
Finally got around it by using #Spektre answer here, I got to play around with the formulas to make it work but it seem fine to me.
Rectified for my needs, it gives:
int alignx= (((x-512)<<8)/241)+Width;
int aligny= (((y-424)<<8)/240)+25+Height;
It works fine as long as the Kinect is at the same level that the object you want to target (ie: no pitch used).
I don't quite agree with Alex Acquier’s answer, it is not the right approach I feel. I have faced the same issue and I know I am doing this 8 months late, but in the interest of others who came here searching for the solution, I now present it here:
The thing is, you don't have to manually align the RGB and the Depth frames. There is a class already available that can do that for you, "IMultiSourceFrameReader". Using this as a source, you can sure to be making the point cloud in the right way.
Now this is okay if you just want to use the feeds. But if somewhere down your code, if you are going to be using some kind of a coordinate system and if you are going to be needing the coordinates of the RGB and the depth pixels, then you would expect them them to be the same, right? Because you are using the aligned coordinates after all, right? But you won't get the coordinates aligned till to use the "ICoordinateMapper" class. This class will make all the coordinates from all the different sensors, RGB and Infra, to align as well and will return the aligned coordinates.
Please refer to this source, it has been my go to source for Kinect V2 since a long time.
I have created JAVA app that uses GifSequenceWriter class for creating animated GIF from PNG sequence but I noticed that gif quality is pretty bad, so I would like to know if there is some option to set the maximum quality which is 256 colors for the output gif as it seems that at the moment (by default) it uses like 128 color only by default at best (or even less!) which is very bad and almost unusable (shadows look terribly with all that color bending for example, no fine detail preserved etc.).
I tested creating the same PNG sequence in separate GIF making tool (a small Windows application) and the output gif is - compared to output from GifSequenceWriter - very very nice (shadows are preserved with all the fine detail, almost invisible color bending etc.) so I guess there most probably should be some kind of IIOMetadataNode .setAttribute() value inside GifSequenceWriter class dealing with the image output quality but I was not able identify it myself...
Or maybe it should be some attribute from imageWriteParam? I searched a bit more and it seems that the actual "quality" parameter - at least for JPEG images - can be set via imageWriteParam.setCompressionQuality(float someFloatValueHere) but when I try that it throw exceptions cos I guess there is no compression quality parameter for GIF...or is it?
Any guess anyone how to solve this issue?
BTW yes I have searched internet - no luck (I cannot even find any list of .setAttribute() options/values anywhere, strange, isn't it?)
EDIT
So after reading link with attribute values provided by #Marco13 I have implemented this code part into GifSequenceWriter:
IIOMetadataNode localColorTableNode = getNode(root, "LocalColorTable");
localColorTableNode.setAttribute("sizeOfLocalColorTable", "256");
localColorTableNode.setAttribute("sortFlag", "FALSE");
IIOMetadataNode colorTableEntryNode = getNode(localColorTableNode, "ColorTableEntry");
colorTableEntryNode.setAttribute("index", someIntA);
colorTableEntryNode.setAttribute("red", someIntB);
colorTableEntryNode.setAttribute("green", someIntC);
colorTableEntryNode.setAttribute("blue", someIntD);
But I have no clue what kind of someIntA/someIntB/someIntC/someIntD int values should I add - any guess anyone, am I going the right direction or what? I kind of feel I may be on the right spot (just maybe!) but I think I need a small kick or something...maybe I do not understand something right here and I need some explanation...or just pure right away solution for those int values...? :)
So I have made a game in eclipse with java for android where a player dodges obstacles that are falling from above and when i tested it on different screen sizes ( Not emulator. real phones! Used a galaxy s4( Bigger screen) and htc(smaller screen)) the speed of the player was different. At the htc the speed was normal but on the galaxy s4 the player was too slow. Its because of the resolution and size differences and now i am just asking for a example of java code how to detect these differences and actually change the speed of the player.I didnt try anything yet except with if statements like:
if (myView.getWidth() < 500)
{
xSpeed = 5;
}
but didnt really work well. If you guys need any more information consider asking please. Im thankful for any kind of help.
I can give you a suggestion which I actually used in my own game because I faced this same issue. The suggestion is: make everything relative i.e. your displacement, velocities, accelerations etc.
For instance if you need to make the speed relative do something like this:
xSpeed = SCREEN_WIDTH/20;
Now if you had a screen width of 200 pixels on one phone, 400 pixels on other and 800 pixels on yet another, your speed will change relatively, being 10, 20, 40 pixels respectively. I hope you understand and please provide code if you require further assistance.
What is the best way to edit singular pixels of an texture multiple times per frame? I have tried using a couple ways to no avail. What is the most optimal way to do this? I have tried using Intermediate mode and drawing each quad, thought, this is really slow.
Edit:
I forgot to mention that I am doing an unusual "fog of war" system. This system doesn't let you see around walls but instead acts like a 2D ray traced shadow. I want these shadows to be pixelated as this is part of the style of the game. I am trying to find the best way to do a form of a shadow map that I can overlay over the world to show what you can see.
I recommend using a Pixel Buffer Object.
I'm looking at creating a program with Processing (processing.org) in Java. The program will involve graphing a large amount of 2D data. I would like for the points to be displayed to fill the window. I've looked at their libraries and I don't see anything for data visualization. Am I missing something?
I've always used JFreechart or, for more complex graphing exporting to a text flie and then gnuplot.
another vote for JFreeChart. Although for more complex graphing I've written my own (AWT).
JUNG Is a favorite of mine.
Processing is really powerful and can be considered a "raw" language given how close you can get to actual graphic programming. I've myself created many graphs and can tell you that you have to be very careful when using this library. It's great but you have to do everything from scratch. This means creating lines for the x and y axis, creating your labels, creating the space, etc.
My suggestion is to set the number of points you'll most likely have, say 1000, and always display with that much data. If you have too little or too much, just adjust it before sending it to graph. This way you'll always have a set number. From here what you do is the following:
pushMatrix();
scale(widthOfGraph/1000, heightOfGraph/numberOfPointsUp);
beginShape(LINES);
for (int i = 0; i < 1000; i++) {
vertex(x0,y0);
vertex(x1,y1);
endShape();
popMatrix();
This will create all your lines in a single drawing operation meaning you'll save a lot of opening and closing shapes. You are also using a stack matrix to use the scale operation to adjust the displaying size of your canvas. Everything else is up to you. Hope that helps.