I cannot view components of an array - arrays

I'm using the following openCV variables:
std::vector<cv::DMatch> best_matches;
std::vector<cv::KeyPoint> tkeypoints[15];
When I press the "." and try to get the components of best_matches, for example best_matches[i].queryIdx then queryIdx appears correctly in the suggestion list.
However, when I try to get the components of tkeypoints, for example tkeypoints[i].angle, I don't see that on the suggestion list and I get an error if I try to run it like that.
Why I can't access the components in the second array?
tkeypoints
best_matches

Since is
std::vector<cv::KeyPoint> tkeypoints[15];
you should access it like:
tkeypoints[i][j].angle

Related

How to map array of objects

I have some problems mapping an array of objects in JS.
This is how the response looks in my console:
[{...}]
...and when I expand it I get this:
0:{id:0, document:{...}}
1:{id:1, document:{...}}
Usually the response I get is always without this number in front of each object, like this:
{id:0, document:{...}
{id:1, document:{...}
I tried every approach I know and I cant't manage to handle it.
The goal is to take each value out of "document" property and dynamically display it in some kind of table.
This is the way the browser devtools decides to display the array, but it is actually correct, if I'm not mistaken you're still dealing with an array.
You can verify this by logging the following:
(Replace myVar with the variable name you chose for your response array)
console.log(Array.isArray(myVar))
If it outputs true then you're fine and you are dealing with an array.

Angular JS - How to find the element in DOM having the xpath?

How can I use xpath instead of id to find the element in DOM. I know that for id I can use: $("#id")[0].
I use $("#id")[0] inside Developer mode in browser in order to get the element by id to see what methods (like .getText(), innerHTML or others) am I able to use for the element. I want to know how to do this by XPATH
Thanks in advance
On Firefox console you can find (and explore) the element like this:
$x("//button[#id='myButton']")
But if you want to call a function on the element, you have to call it like this:
$x("//button[#id='myButton']")[0].click()
because there is always an array of elements returned (provided that the element is present and the first one in the array).
Thanks for the comments. I found out the answer. It can be done with:
$x("xpath")

Drupal 7 - Render view after views_get_view_result

How do I render the view result that I get by calling "views_get_view_result"
So right now I have:
$variables['result'] = views_get_view_result('name', 'name-block');
And it returns an array of Object, which is what I want. Just can't figure out how to render it. Trying to render $result[0], $result[1] for example.
Thanks,
Tee
For a simple way of doing this, use
print views_embed_view('view_name', 'display_id');
which is a utility function for doing what you want to do. See https://api.drupal.org/api/views/views.module/function/views_embed_view/7
Here is a thread with additional ways of doing this, if you need the extra complexity / depth. https://drupal.org/node/951442

How to declare, same webelement with different ids using Findby?

For instance, is it possible to define:
#FindBy(By.id("id1") OR By.id("form1:id1"))
public WebElement button
So that button having either "id1" or "form1:id1" should work fine?
You can use the #FindBys annotation, the syntax is:
#FindBys({#FindBy(id = "foo"),
#FindBy(className = "bar")})
The JavaDoc describes it here:
http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/support/FindBys.html
Well,
use whathever you want, as long as it works
Personally I would use #FindBy(By.id("id1")) but it is just point of choice.
Also, there is no value added in referring same element twice with two different methods. It will only cause mess in your code
EDIT
As I understood your comment, there is element on the page which constantly changes its ID. If you need to refer to such elements, try using xPath See for example this xpath tutorial
The idea is that you will point to some place in the DOM rather than to specific ID
Use Xpath or CSS selector to do that. Or Java to store the ID name in String and then you can fill it to your Id.

How to access a main document class array from a movieclip?

I have an array in my main
public var graphArray:Array = [1,2,3,4,5,6];
And I'm trying to access it from within a MovieClip that I've put on my timeline using:
var graph1scale:Number = MovieClip(root).graphArray[0]
It looks like it would make sense to me but when I try to run it I get this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
Am I wrong to be using MovieClip(root) to try and access it? I've only just started using external classes (this is my first project doing so) and usually I just do everything on the timeline. So MovieClip(root) is familiar to me but I guess it's not the right thing to do here.
Is there a way I can access vars from Main.as?
-----SOLVED-----
I realised MovieClip(root) did work all along but I was just calling on the array before the array was being defined in Main.as. I put a delay on calling graphArray and it worked.
Not sure how that makes sense though because the graphArray is the first thing I've defined in the whole main.as class
Try using this instead
MovieClip(this.root)
This works for me on a test that you can see here:
http://marksost.com/test/as3arrayaccess/
And the source files here:
http://marksost.com/test/as3arrayaccess/test.zip

Resources