how can I config the ar drone to detect tags using node.js? - node.js

I am using parrot ar drone 2.0 and trying see if it detects the oriented roundel. This is a part of my code:
client.config('CAD_TYPE_ORIENTED_ROUNDEL_BW', 12);
client.config('general:navdata_demo', 'FALSE');
and later i have:
console.log('cameraSource:' + d.visionDetect.cameraSource);
console.log('tag_count:' + d.visionDetect.nbDetected);
console.log('tag_type:' + d.visionDetect.type);
But the number of tags and everything remains zero despite the drone moving above the tag.
I am a bit new to node.js so can somebody please tell me what the problem is?

Apparently you need to type all configurations in lower case letters.
so with this configuration it can detect it.
client.config('detect:detect_type', 12);
number 12 corresponds to the black and white oriented roundel.

Related

Vuforia video playback with fixed dimension

I am using vuforia video playback demo with cloud recognition.
I have combined both projects and it is working properly. But currently video dimension is according to detected object. But i need fixed width and height when video plays.
Can anyone help me ?
Thanks in advance.
Well apparently Vuforia fixes the width and height at the start of the game no matter what the size of the object is. I could not find when exactly this operation is conducted but it is done at beginning of your game. When you change the size of the ImageTarget in runtime it is not fixed anymore. Add these lines to your OnTrackingFound function of DefaultTrackableEventHandler.cs
if (this.name == "WhateverTheNameOfYourRelatedImageTarget"&& !isScaled)
{
//Increase the size however you want i just added 1 to each dimension
this.transform.localScale += Vector3.one;
// make isScaled true not to scale every time it is found initially it shoud be false
isScaled = true;
}
Good luck!
What i usually do is , instead of Videoplayback , i play the video on canvas object and hook this object to Defaulttrackableeventhandler script. So when target is found, gameobject.setactive(true) and gameobject.setactive(false) when target is lost. By this method the size of the gameobject is fixed and it stays in a fixed location .
I just made an example you can get here (have to import it to any project and open the scene Assets/VideoExample/Examples). You can see there a bit clearer what the ScreenSpace - Overlay does ... it might be better to just switch to ScreenSpace - Camera in general

Can a 3 axis magnetometer reading be converted to the way(north/south/east/west) drone is heading?

I have parrot AR drone 2.0 elite edition. And i read couple documents which says that i can get the magnetometer reading such as magX, magY and magZ. Also the YAW. Is there anyway to calculate the direction my drone is heading(north/south/east/west or northeast and such) by using these values? It also has 3 axis gyroscopes and a 3 axis accelerometer. I am probably going to use nodejs. Any help is greatly appreciated. Thank you.
This documentation might help a little explaining magnetometer
http://arcbotics.com/products/sparki/parts/magnetometer/
Yes, you can get the drone's heading from the navdata. If you're using the node library ar-drone, then you can do something like this:
var arDrone = require('ar-drone');
var client = arDrone.createClient();
client.on('navdata', function(data) {
console.log('Heading: ' + data.magneto.heading.fusionUnwrapped);
});
magneto.heading.fusionUnwrapped will be the drone's heading, in degrees. You can see another example of it being used in the ardrone-webflight project, here where it uses heading to update the HUD's compass display.

making objects constantly in a while loop

I'm doing a project for a year 11 physics class and I'm trying to make a battery that generates electrons. This is the code:
electron = sphere(radius = 1, color = color.yellow, vel = vec(-1,0,0));
while battery.voltage > 0:
eb = electron.clone(pos=vec(0,0,0), vel = vec(-1,0,0));
I'm trying to make "eb" constantly, but it only applies eb.pos = eb.pos + eb.vel * deltat; apply to a the first electron. Is there any way to do this without making 600 different electron objects?
You could change the attribute that is modified directly to the electron object instead of creating it all the time. Apply the modifications to electron and add the computing action in the while. Is it what you meant?
You definitely need to make and move 600 sphere objects in order to have 600 sphere objects move. Your variable "eb" is just the name of the most recently made clone of the original sphere.
I'll advertise that a better place to pose VPython questions is in the VPython forum at
https://groups.google.com/forum/?fromgroups&hl=en#!forum/vpython-users

OpenCV store image in Object (OOP)

I'm programming in C++ using OpenCV in an object oriented approach. Basically I have an array of object called People[8]. For each array, I want to allocate an image to it by taking a picture using webcam. I did something like this:
for (int i=0; i<8; i++){
cvWaitKey(0); //wait for input then take picture
Mat grabbed = cam1.CamCapture();
People[i].setImage(grabbed);
imshow("picture", grabbed);
cvWaitKey(1);
}
I face 2 problems here:
1) The imshow does not display the 'latest' image captured, it display the image previously taken i.e (i-1) instead of i.
2) When I display all the images together, 8 windows appear and all of them are displaying the last image captured on the camera.
I do not have any clue what is wrong, could anyone please advice? Thank you in advance.
"all of them are displaying the last image captured on the camera."
the images you get from the capture point to driver memory. so the former image gets overwritten by the latter.
you need to store a clone() of the mat you get, like:
People[i].setImage( grabbed.clone() );
I have not worked with OpenCV for a while but I would move around cvWaitKey( 1 ), I also would not have 2 calls to it, from what I remember it is similar to glFlush(). Also I would change 1 to 10. For some reason I remember 1 not working.

When I load an image in OpenCV it is always darker than the original. Why?

So I load a color .png file that has been taken with an iphone using cvLoadImage. And after it's been loaded, when I immediately display it in my X11 terminal, the image is definitely darker than the original png file.
I currently use this to load the image:
IplImage *img3 = cvLoadImage( "bright.png", 1);
For the second parameter I have tried all of the following:
CV_LOAD_IMAGE_UNCHANGED
CV_LOAD_IMAGE_GRAYSCALE
CV_LOAD_IMAGE_COLOR
CV_LOAD_IMAGE_ANYDEPTH
CV_LOAD_IMAGE_ANYCOLOR
but none of these have worked. Grayscale definitely made the image grayscale. But as suggested from http://www.cognotics.com/opencv/docs/1.0/ref/opencvref_highgui.htm, even using CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR to load the image as truthfully as possible resulted in a darker image being displayed in the terminal.
Does anyone have any ideas on how to get the original image to display properly?
Thanks a lot in advance.
Yes, OpenCV does not apply Gamma correction.
// from: http://gegl.org/
// value: 0.0-1.0
static inline qreal
linear_to_gamma_2_2 (qreal value){
if (value > 0.0030402477)
return 1.055 * pow (value, (1.0/2.4)) - 0.055;
return 12.92 * value;
}
// from: http://gegl.org/
static inline qreal
gamma_2_2_to_linear (qreal value){
if (value > 0.03928)
return pow ((value + 0.055) / 1.055, 2.4);
return value / 12.92;
}
It only happens when you load it in OpenCV? Opening with any other viewer doesn't show a difference?
I can't confirm this without a few tests but I believe the iPhone display gamma is 1.8 (source: http://www.colorwiki.com/wiki/Color_on_iPhone#The_iPhone.27s_Display). Your X11 monitor probably is adjusted for 2.2 (like the rest of the world).
If this theory holds, yes, images are going to appear darker on X11 than on the iPhone. You may change your monitor calibration or do some image processing to account for the difference.
Edit:
I believe OpenCV really does not apply gamma correction. My reference to this is here:
http://permalink.gmane.org/gmane.comp.lib.opencv.devel/837
You might want to implement it yourself or "correct" it with ImageMagick. This page instructs you on how to do so:
http://www.4p8.com/eric.brasseur/gamma.html
I usually load an image with:
cvLoadImage("file.png", CV_LOAD_IMAGE_UNCHANGED);
One interesting test you could do to detect if OpenCV is really messing with the image data, is simply creating another image with cvCreateImage(), then copy the data to this newly created image and save it to another file with cvLoadImage().
Maybe, it's just a display error. Of course, I would suggest you to update to the most recent version of OpenCV.

Resources