LibGDX batch.draw vs sprite.draw performance [closed] - performance

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
which performance is better between A and B?
A :
batch.draw(sprite, x, y, width, height);
B :
sprite.draw(batch);
sprite.setPosition(x,y);
rotation or resizing may be involved.
if you think about performance rather than convenience, what would be better?

These don't have equivalent results, so there's no point in comparing their performance. The first (A) completely ignores all characteristics of the Sprite like color, position, scale, and rotation. It should never be used and is only possible because of the unfortunate design decision to have Sprite be a subclass of TextureRegion. A design mistake that I think the original creators of libGDX admit based on comments made on GitHub.
The Sprite class in my opinion should not be used at all in most cases since it conflates a TextureRegion (image asset) with a game world object (simulation data). You should define your own GameObject class that has a TextureRegion variable and variables for the characteristics that you are using (width, height, scale, etc.). Then draw it using whichever batch.draw overload has parameters for all the characteristics you use.
To take it a step further, you can write your own Drawable abstract wrapper class that can has variants for holding either a TextureRegion or an Animation<TextureRegion>. Then you GameObject can reference a Drawable, and you can easily swap out different types of assets for a GameObject.

Related

depth map extraction from single image [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
please help me.
I'm looking for a simple algorithm that its input is a single image and that's it. The output will be a depth map of the image with colors of pixels according to if they are near or far from the camera.
I am looking for a simple solution without Machine Learning, 3D model, sterioscopic input or user input help. Only a single image.
thank you
What you are asking is in general an ill posed problem.
However, recent work with deep-networks have shown that a depth map can be predicted from a single image.
Here's one such paper: Depth Map Prediction from a Single Image
using a Multi-Scale Deep Network.
From the abstract:
Predicting depth is an essential component in understanding the 3D
geometry of a scene. While for stereo images local correspondence
suffices for estimation, finding depth relations from a single image
is less straightforward, requiring integration of both global and
local information from various cues. Moreover, the task is inherently
ambiguous, with a large source of uncertainty coming from the overall
scale. In this paper, we present a new method that addresses this task
by employing two deep network stacks: one that makes a coarse global
prediction based on the entire image, and another that refines this
prediction locally. We also apply a scale-invariant error to help
measure depth relations rather than scale. By leveraging the raw
datasets as large sources of training data, our method achieves
state-of-the-art results on both NYU Depth and KITTI, and matches
detailed depth boundaries without the need for superpixelation.

How do I detect overlapping almost circular objects in MATLAB? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm working on a project which involves detecting the red blood cells in the blood. RBCs in the blood are never perfectly circular (usually almost eliptical) and they often overlap.
I've searched and found a number of algorithms, but most work for circles only. However, in my case it needs to work for blood from patients with sickle cell disease, where the RBCs are elongated or sickle-shaped. For reference here is an example source image.
Can you suggest an algorithm or approach to solve this problem?
Any help would be greatly appreciated.
As mentioned in the comments, this question is really too broad to answer completely. However, I can give you some pointers in how to address this.
For starters, get yourself the MATLAB Image Processing toolbox.
"Identify red blood cells" is a deceptively simple-sounding task. The first step with any project like this is to figure out what exactly you want to achieve, then start breaking it down into steps of how you will achieve that. Finally, there is the experimental-developmental stage where you try and implement your plan (realise what is wrong with it, then try again).
Cell counting normally uses circularity to identify cells, but that's not possible here because you state you want to identify sickle cells. The other main characteristics distinguishing RBCs from other cells is the colour and size. The colour is more absolute, so start with that. Then think about size. This is a good tutorial on the process of identifying cells although it is in Python the principle is the same.
So we have:
Apply a filter to your image, either isolating the red channel (RGB) or something more complex. Make it monochrome (we don't need colour data).
Smooth the image (e.g. gaussian filter) to reduce the noise and artefacts
Find regional maxima which are (hopefully!) in the center of cells
Label the regional maxima (this should give you the number of cells)
Watershed to find the whole cells an measure size
Hopefully that is enough to get you started!

More realistic perspective algorithms [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
As I noticed, many 3D games (almost all, I think) use simple algorithm for computing perspective. It works almost ideal, but all objects significantly deform at the edges of the FOV. The sipliest example of this effect is the fact that all spheres at the edges of FOV look not like circles.
The OpenGl function gluPerspective() creates perspective with same defect.
I have a rough idea of better algorithm that, as I think, will fix this problem.
So, question is:
Is there any algorithms that don't have this defect and where I can read about them?
Is there any algorithms that don't have this defect and where I can read about them?
There are several: Spherical projections, Stereographic projections. Cylindrical projections. Tiled panoramic projections, and so on, you name it.
Rastering systems that are based on triangles however have a very important requirement on the projection to work properly: Straight lines must be projection into to straight lines (affine projection). This is the cause for the unpleasant distortions you see. Any of the projections I mentioned above (and many more) can be approximated with OpenGL using an appropriate vertex shader. However to look good the geometry must be sufficiently fine tesselated, because straight edges need to be broken down into sufficiently many segments to allow mapping to curves. A tesselation shader can be used for this. Another approach is rendering a wide field view into a cube map (cube maps require an affine projection for their creation). Then you can apply and other mapping on the cubemap, which leads to more robust results.

2d data matrix(barcode) detection algorithm is not giving me results [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am working on detection of 2d data matrix but there is a problem in detection because barcode changes its design in each product so how to detect it? can anybody help me ?
The specification of datamatrix is designed to be identified. You need to look at the code the way it is intended to be looked at. Where I'd start is that the code has a quiet zone and an "L" pattern. That is what you are looking for.
How you go about doing this depends a lot on the general parameters of the image.
The first consideration is lighting and contrast. Can you depend on having a fixed midpoint, where everthing lighter is called white and everything darker black? Or will a simple histogram give a usable midpoint? Or do shadows and uneven lighting cause a value to be called black on the sunny side of the image and the same tone white on the shadow side of an image? On a flatbed scanner it is easy to depend on good contrast, but camera phone photos are more problematic.
The next consideration is size and resolution. For a camera phone application, it is expected that in a low resolution image, a high percentage of the image will contain the barcode, while a scanner may have a lot of image and a little amount of barcode data which needs to be searched for.
Finally comes presentation. Will the barcode appear in 360 degrees of rotation? Will it be flat and level or can it be be skewed, curled and angled? Is there any concern about lens distortion?
Once you can answer the considerations, it should point to what you need to do to identify the barcode. Datamatrix has clocking marks which enable distorted codes to be read, but it is a lot more work to define distortion, so if it is not needed, you wouldn't do it.

360 degree field-of-view without stitching? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Is there any type of camera that can have a 360 degree field of view with just one single shot, without using any stitching algorithms and post-processing steps? Or, is it possible to have one such camera with the appropriate use of lenses and other optical components?
I think that the closest you can get to a one-shot panorama is using a mirrored ball - there are a number of resources on how to use them scattered across the web. The short version is that you set up the mirrored ball and shoot its reflection, then post-process to unwrap the image. If you shot vertically down (or up) into the ball, you would get a 360 degree view of the scene; however, owing to the shape of the mirror, the resolution will drop off as you approach the ball's horizon.
Though the mirrored ball images are cool on their own, you will most likely still want to post-process the image. I've used panotools before and can vouch for them. They have a built-in ability to remap mirrored ball images to latitude-longitude (what we're more used to seeing as panoramas).
To really get it right, you could build a custom mirror rig and do the math to remap the mirrored images to your panorama. This is e.g. how the Google Street View cars do it - they have what looks like a cone of mirrors on the car, and they post-process the image from the mirrors. Of course, this is moving heavily toward the post-processing effort, but it is a true one shot one camera 360 degree panorama.
I'm not aware of manufactured cameras for such a thing. But you can rig 2 fisheye cameras into one unit. I'm not sure why you don't want software. Unless your using a hemisphere screen, you have to correct for your screen. There are open source switchers but I like Microsoft's ICE
http://research.microsoft.com/en-us/um/redmond/groups/ivm/ice/

Resources