Hey there I work with the aruco library and with ROS thus I currently use this code:
https://github.com/joselusl/aruco_eye
I have this output(x pointing right, y out of the image and z down)
What I basically want is:
x pointing right, y up and z out of the image
Is there a simple way in the aruco lib definition of how to set the coordinate system? Or do I have to turn it afterwards?
So currently the aruco lib is configured like this:
const aruco::MarkerDetector::ThresholdMethods ARUCO_EYE_CONFIG_thresholdMethod=aruco::MarkerDetector::ADPT_THRES;
const double ARUCO_EYE_CONFIG_ThresParam1=7;
const double ARUCO_EYE_CONFIG_ThresParam2=7;
const aruco::MarkerDetector::CornerRefinementMethod ARUCO_EYE_CONFIG_methodCornerRefinement=aruco::MarkerDetector::LINES;
const float ARUCO_EYE_CONFIG_minSize=0.045;//0.03;
const float ARUCO_EYE_CONFIG_maxSize=0.5;//0.5;
//configure aruco detector
if(MyArucoEye.configureArucoDetector(ARUCO_EYE_CONFIG_thresholdMethod,
ARUCO_EYE_CONFIG_ThresParam1,
ARUCO_EYE_CONFIG_ThresParam2,
ARUCO_EYE_CONFIG_methodCornerRefinement,
ARUCO_EYE_CONFIG_minSize,
ARUCO_EYE_CONFIG_maxSize) )
You can use tuw_aruco it publishes tf, already and is easy to configure.
Related
I'm using Cocos2d-js v3 to create a jackpot-spinner. When I'm rotating the spinner wheel sprite, it wobbles, as in it moves in x,y axis slightly too while rotataing. How can I keep the sprite fixed while rotating? I'm new to Cocos2d-js.
Here is my creating the sprite code -
sprite = new cc.Sprite.create(res.wheel_png);
sprite.setPosition(cc.p(size.width/2, size.height/2));
this.addChild(sprite, 0);
And rotation code -
var rand = Math.random();
var sprite_action = cc.RotateBy.create(2, 1370);
var repeat_action = cc.Repeat.create(sprite_action, rand);
sprite.runAction(repeat_action);
Create method is deprecated, as are some others. Check out this page for list of all things deprecated.
As per the cocos docs for v3, (look up "rotateby")
Field Detail <static> {cc.RotateBy} cc.RotateBy.create
Please use cc.rotateBy instead. Rotates a cc.Node object clockwise a number of degrees by modifying it's rotation attribute. Relative to its properties to modify.
Deprecated:since v3.0
Please use cc.rotateBy instead.
You need to use it like this:
var rand = Math.random();
var sprite_action = cc.rotateBy(2, 1370);
var repeat_action = cc.repeat(sprite_action, rand);
sprite.runAction(repeat_action);
I have a 3D scene with a bunch of CSS object that I want to rotate so that they are all pointing towards a point in the space.
My CSS objects are simple rectangles that are a lot wider than they are high:
var element = document.createElement('div');
element.innerHTML = "test";
element.style.width = "75px";
element.style.height = "10px";
var object = new THREE.CSS3DObject(element);
object.position.x = x;
object.position.y = y;
object.position.z = z;
Per default, the created objects are defined as if they are "facing" the z-axis. This means that if I use the lookAt() function, the objects will rotate so that the "test" text face the point.
My problem is that I would rather rotate so that the "right edge" of the div is pointing towards the desired point. I've tried fiddling with the up-vector, but I feel like that wont work because I still want the up-vector to point up. I also tried rotating the object Math.PI/2 along the y axis first, but lookAt() seems to ignore any prior set rotation.
It seems like I need to redefine the objects local z-vector instead, so that it runs along with the global x-vector. That way the objects "looking at"-direction would be to the right in the scene, and then lookAt() would orient it properly.
Sorry for probably mangling terminology, newbie 3D programmer here.
Object.lookAt( point ) will orient the object so that the object's internal positive z-axis points in the direction of the desired point.
If you want the object's internal positive x-axis to point in the direction of the desired point, you can use this pattern:
object.lookAt( point );
object.rotateY( - Math.PI / 2 );
three.js r.84
I'd like to learn Rust and thought it would be fun to procedurally generate images. I've no idea where to start though... piston/rust-image? But even with that where should I begin?
The place to begin is the docs and the repository.
It's not immediately obvious from the landing page of the documentation, but the core type in image is ImageBuffer.
The new function allows one to construct an ImageBuffer representing an image with the given/width, storing pixels of a given type (e.g. RGB, or that with transparency). One can use methods like pixels_mut, get_pixel_mut and put_pixel (the latter are below pixels_mut in the documentation) to modify the image. E.g.
extern crate image;
use image::{ImageBuffer, Rgb};
const WIDTH: u32 = 10;
const HEIGHT: u32 = 10;
fn main() {
// a default (black) image containing Rgb values
let mut image = ImageBuffer::<Rgb<u8>>::new(WIDTH, HEIGHT);
// set a central pixel to white
image.get_pixel_mut(5, 5).data = [255, 255, 255];
// write it out to a file
image.save("output.png").unwrap();
}
which looks like:
The repo is particularly useful as a starting point, because it contains examples, in particular, it has an example of programmatically generating an image. When using a new library, I'll open the docs, and, if confused, the repo specifically to look for examples.
NOTE:
get_pixel_mut Deprecated since 0.24.0: Use get_pixel and put_pixel instead.
As #huon answer is 6 years old, I was getting errors reproducing the result, so I wrote this,
use image::{ImageBuffer, RgbImage};
const WIDTH:u32 = 10;
const HEIGHT:u32 = 10;
fn main() {
let mut image: RgbImage = ImageBuffer::new(WIDTH, HEIGHT);
*image.get_pixel_mut(5, 5) = image::Rgb([255,255,255]);
image.save("output.png").unwrap();
}
I'm trying to make a time lapse geographic twitter visualization inspired by Jer Thorp's "Just Landed". I am using the latest version of processing.
I'm using an SVG image for my map because I want to be able to zoom into the map at an arbitrary angle, to focus on certain localities, then show the twitter connections on a global scale. I'm running into several problems, the first of which is a flickering of path boundaries of the countries when I rotate my map. Here's a screenshot of my problem:
Here is my code which is causing the problem:
import processing.opengl.*;
import java.awt.event.*;
PShape map;
PShape test1;
PShape test2;
//camera position/movement intialization
PVector position = new PVector(450, 450);
PVector movement = new PVector();
PVector rotation = new PVector();
PVector velocity = new PVector();
float rotationSpeed = 0.035;
float panningsSpeed = 0.035;
float movementSpeed = 0.05;
float scaleSpeed = 0.25;
float fScale = 2;
void setup(){
map = loadShape("blank_merc.svg"); //swap out for whatever file
size(900, 900, OPENGL);
smooth();
fill(150, 200, 250);
addMouseWheelListener(new MouseWheelListener(){
public void mouseWheelMoved(MouseWheelEvent mwe){
mouseWheel(mwe.getWheelRotation());
}
});
}
void draw(){
if (mousePressed) {
if (mouseButton==LEFT) velocity.add( (pmouseY-mouseY) * 0.01, (mouseX-pmouseX) * 0.01, 0);
if (mouseButton==RIGHT) movement.add( (mouseX-pmouseX) * movementSpeed, (mouseY-pmouseY) * movementSpeed, 0);
}
//TODO: implement reset functionality: DONE
if (keyPressed){
if (key=='r'){
position.set(450,450);
rotation.sub(rotation.get());
velocity.sub(velocity.get());
movement.sub(movement.get());
}
}
velocity.mult(0.95);
rotation.add(velocity);
movement.mult(0.95);
position.add(movement);
background(255);
//lights();
translate(position.x, position.y, position.z);
rotateX(rotation.x*rotationSpeed);
rotateY(rotation.y*rotationSpeed);
scale(fScale);
shape(map,-250,-250,1000,1000);
}
void mouseWheel(int delta){
fScale -= delta * scaleSpeed;
fScale = max(0.5, fScale);
}
I was told it might be z-fighting amongst the paths, and I think this might be the problem because the flickering is more problematic when the map is mid rotation, especially at angles that are non orthogonal to the viewing plane. I tried to remedy this by "translating" a PShape child of the file a small amount in the Z direction with the test1.translate(0,0,0.1); command, but I get an error telling me illegal argument exception: cannot use translate(x,y,z) on a PMatrix2D.
I've also had trouble testing my code with other SVG map files and generally getting the SVG to look like what I think it should look like. There are a bunch of cities and other weird markers on my SVG map, and even when i download the completely "blank" svg world map mercator projection from wikimedia commons. There are these city marker/region attributes which show up in the processing render that dont show up in the browser view. I'm trying to figure out how to "clean" my SVG file up in Inkscape, but I'm unsure what specifically to look for.
For example, I've run it with this map: http://commons.wikimedia.org/wiki/File:Mercator_Projection.svg
but the dots and lines I have no use for, and I'm having to resort to manually selecting and deleting the paths, which is not a very thorough process
and when I use this map, which is supposed to be the "blank version" of the above without all the markers, I see not only a bunch of markers (presumably hidden with some style attribute in the SVG XML?) but also this weird vertical banding, and my camera controls are super slow. The applet appears to be behaving as if the file is way too large, but its like 2MB. Here's a screenshot of what this looks like:
I'm really just looking for a way to get a "clean" SVG world map into Processing so I can spin it around and zoom in on it, and if I can get that to work I can start the Arc-Drawing part. I would sincerely appreciate any assistance anyone could give me.
Thanks
If I understand your question correctly, the flickering is only on the edges, presumably where they overlap. That would suggest z-fighting to me. I usually find that a simple test outside your main sketch is best, just as a quick way to see what's happening and how you might fix it.
If you make a simple SVG with two overlapping shapes, sharing just one edge, does the same thing happen?
If so, I think the easiest solution (though not that easy) would be either:
Select all the countries in Illustrator
Use Object > Transform > Scale... and shrink by a tiny amount
Then share your fixed map for everyone else!
Quancomm Augmented Reality (QCAR) for iOS, which make use of OpenGL ES, to display 3D model. It reads several files:
vertices, texture coordinates, indices & normals list (in format of ONE .h header file, e.g. Teapot.h)
texture file (in PNG format)
shader file (in FSH and VSH format)
My question is, how to convert a 3D Studio Max (3ds/max) file to the vertices, texture coordinates, indices & normals list? Also, during the conversion process, can the shader file be generated based on the settings in 3DS file as well?
The files are used in QCAR SDK for iOS, version 1.0.
As an example, the file content is as follow:
#ifndef _QCAR_TEAPOT_OBJECT_H_
#define _QCAR_TEAPOT_OBJECT_H_
#define NUM_TEAPOT_OBJECT_VERTEX 824
#define NUM_TEAPOT_OBJECT_INDEX 1024 * 3
static const float teapotVertices[NUM_TEAPOT_OBJECT_VERTEX * 3] =
{
// vertices here
};
static const float teapotTexCoords[NUM_TEAPOT_OBJECT_VERTEX * 2] =
{
// texture coordinates here
};
static const float teapotNormals[NUM_TEAPOT_OBJECT_VERTEX * 3] =
{
// normals here
};
static const unsigned short teapotIndices[NUM_TEAPOT_OBJECT_INDEX] =
{
// indices here
};
#endif
i believe that what you are looking for, is here: 3DS to Header utility.
In answer to your second question, 3DS material settings could be in theory converted to shaders if someone wrote all possible shaders that 3DS can use and programmed some code to select and configure the shader, based on material properties. But no, there is no direct / easy way how to do that. Although, if i recall correctly, 3DS doesn't have too many material choices so there might be not too many shaders required in order to do this.