I have a horizontal scrollview like below with V as an overlay and it acts like a pointer:
V
[ 0 ] , [ 1 ] , [ 2 ] , [ 3 ] , [ 4 ] , [ 5 ]
^
When I scroll, I would like to print the value or index that is in the current pointer.
Eg. scroll until [2] and it will print "2".
V
[ 2 ] , [ 3 ] , [ 4 ] , [ 5 ]
^
Could you guide me on how to achieve this?
I ended up using offset for this. Set a fixed width for a column, then we can calculate the offset for each column.
Related
I deployed SSD VGG16 Atrous 300 model(COCO 2017, from Gluon CV) by AWS SageMaker JumpStart. Response from pretrained model contains normalized_boxes with values bigger than one(1), e.g.
"normalized_boxes": [
[
0.4935379866715316,
0.20722445845603943,
0.7275399344308036,
0.7329685688018799
],
[
1.9931350875686813,
0.15846982598304749,
2.275825517256181,
0.5962902307510376
],
...
"classes": [
0,
0,
...
"scores": [
0.344256728887558,
0.4128507971763611,
...
"labels": [
"person",
"bicycle",
...
"mxnet_model_output": [
[
[
[
0
],
[
0
],
...
[
[
[
0.9202409386634827
],
[
0.9055193662643433
],
...
[
[
[
1551.213134765625,
589.4755249023438,
1808.19921875,
878.4844360351562
],
[
1557.686767578125,
310.9128112792969,
1805.559814453125,
587.8072509765625
],
...
How to read those bounding boxes?
I didn't manage to find the answer on gluon(https://cv.gluon.ai/model_zoo/detection.html)
The model can be fine-tuned, the rules how to prepare annotations(available in model description):
"The annotations.json file should should have information for bounding_boxes and their class labels. It should have a dictionary with keys "images" and "annotations". Value for the "images" key should be a list of entries, one for each image of the form {"file_name": image_name, "height": height, "width": width, "id": image_id}. Value of the 'annotations' key should be a list of entries, one for each bounding box of the form {"image_id": image_id, "bbox": [xmin, ymin, xmax, ymax], "category_id": bbox_label}."
names of attributes are the same as in the COCO dataset - https://www.immersivelimit.com/tutorials/create-coco-annotations-from-scratch/#coco-dataset-format
only this part is not consistent with COCO: "[xmin, ymin, xmax, ymax]" as I found, COCO has "[x_min, y_min, width, height]"(https://albumentations.ai/docs/getting_started/bounding_boxes_augmentation/)
I tired also SSD VGG16 Atrous 512(pre-trained on VOC dataset) and faced the same problem, additionally, I received bbox value with a minus:
"normalized_boxes": [
[
0.9567698719737294,
-0.14875292778015137,
1.0963617010430975,
0.5834765434265137
],
...
How to deal with values smaller than 0?
I wrote Lists (Name, Item, etc.) for my Green Mountain Outpost Applikation.
I want the applikation to run automaticaly the testcase with 1 Persone and Item at the time. So that the app. runs 1 Person from list throug, than the second test with another.
Testcase
Function
List for Name, Item, etc.
[ ] int x = 1
[-] for each Name in customers
[ ] print(Name)
[ ] // Name = customers[x]
[ ] Artikel = items[x]
[ ] CardN = cardnumber[x]
[ ] Expi = expirationdate[x]
[ ] print(Artikel)
[ ] print(CardN)
[ ] print(Expi)
[ ] print("----------------------")
[ ] Bestellung (Name, Artikel, CardN, Expi)
[ ]
[ ] x++
You can mention the data in Excel and make the test case as data driven.
Each row will be having one data combination.
I need to model a nested data structure with an array of an array of numbers. Ex:
"measures": [
[1, 91.3],
[2, 87.5],
...
I tried like this:
"mmeasures": {
"type": [ [ "Number" ] ]
},
But it does not seem to work.
The corresponding loopback docs do not mention nested arrays.
An array of any typed values did the trick:
"mmeasures": {
"type": [ "any" ]
},
Using the glm library for the calculations. I have a mesh located in a local coordinate system where the axis are:
meshUp = glm::vec3(0, 1, 0);
meshForward = glm::vec3(0, 0, -1);
meshRight = glm::vec3(1, 0, 0);
and I need a matrix that will rotate its vertices to any other new coordinate system with 3 given axis, fx:
newUp = glm::vec3(-0.85, 0.51, -0.08);
newForward = glm::vec3(0.45, 0.65, -0.61);
newRight = glm::vec3(-0.26, -0.56, -0.79);
No translation needed, the coordinate systems share origin. I can get halfway there, like this:
glm::vec3 rotationVecForUpAxis = glm::normalize(glm::cross(meshUp, newUp));
float rotationRadiansForUpAxis = acos(glm::dot(meshUp, newUp));
glm::mat4 rotationMatrix = glm::rotate(glm::mat4(),
rotationRadiansForUpAxis,
rotationVecForUpAxis);
This works and rotates the mesh, so it's up axis aligns with the newUp axis. However, the mesh still needs to be rotated around the newUp axis, before the mesh's meshForward axis aligns with the newForward axis.
Does anyone know how to do this?
You could look up the math. But just for the fun of it, I'm going to derive it here.
Let's say that the new basis vectors, expressed in the original coordinate system, are:
[ xnx ] [ ynx ] [ znx ]
xn = [ xny ] yn = [ yny ] zn = [ zny ]
[ xnz ] [ ynz ] [ znz ]
You're looking for the matrix M that maps these vectors to the basis vectors in the new coordinate system:
[ xnx ] = [ 1 ] [ ynx ] = [ 0 ] [ znx ] = [ 0 ]
M * [ xny ] = [ 0 ] M * [ yny ] = [ 1 ] M * [ zny ] = [ 0 ]
[ xnz ] = [ 0 ] [ ynz ] = [ 0 ] [ znz ] = [ 1 ]
Writing this in matrix form gives:
[ xnx ynx znx ] = [ 1 0 0 ]
M * [ xny yny zny ] = [ 0 1 0 ]
[ xnz ynz znz ] = [ 0 0 1 ]
Which in turn gives for M:
[ xnx ynx znx ]
M = inverse( [ xny yny zny ] )
[ xnz ynz znz ]
In words, the matrix is the inverse of the matrix that has the new basis vectors as its columns.
For a rotation, this becomes particularly easy. The inverse of a rotation matrix is the transpose of the matrix. So M is the matrix with the new basis vectors as its rows:
[ xnx xny xnz ]
M = [ ynx yny ynz ]
[ znx zny znz ]
With this, all you need to get your rotation matrix is build a matrix that has the values of the new basis vectors as its rows. For example, if you use newRight as the x-axis, newUp as the y-axis, and newForward as the z-axis, the transformation matrix is:
[ newRight.x newRight.y newRight.z ]
[ newUp.x newUp.y newUp.z ]
[ newForward.x newForward.y newForward.z ]
When building the matrix, keep in mind that matrices for OpenGL are commonly stored in column major order.
I have follwoing collection structure -
{
"_id": ObjectId("54c784d71e14acf9ae833f9f"),
"vms": [
{
"name": "ABC",
"ids": [
"abc.60a980004270457730244662385a4f69",
"abc.60a980004270457730244662385a4f6d"
]
},
{
"name": "PQR",
"ids": [
"abc.6d867d9c7acd60001aed76eb2c70bd53",
"abc.60a980004270457730244662385a4f6d"
]
},
{
"name": "XYZ",
"ids": [
"abc.600605b00237d91016cdc38f376bd31d",
"abc.600605b00237d91016cdc38f376cd32f"
]
}
]
}
I have an array which contains substrings of ids. here is an array for your reference -
myArray = [ "4270457730244662385a4f69","4270457730244662385a4f6d" , "4270457730244662385a4f6b"]
I want to find each element of myArray is not present in ids as a substring using mongo.
Currently I am able to find single element using regex in mongo.
In above example, I want output as:
[
{
"name": "XYZ",
"ids": [
"abc.600605b00237d91016cdc38f376bd31d",
"abc.600605b00237d91016cdc38f376cd32f"
]
}
]
How do I find substring in array using mongo??
It is possible to do it using regex. You can match the string for multiple substrings using or operator. It is | in regex. Search for 'Boolean "or"' on wikipedia
MongoDB query using aggregation:
db.collection_name.aggregate([
{$unwind: "$vms"},
{$match: {
"vms.ids": {$not: /.*(4270457730244662385a4f69|4270457730244662385a4f6d|4270457730244662385a4f6b).*/}}
}
])
Output will be
{
"_id" : ObjectId("54c784d71e14acf9ae833f9f"),
"vms" : {
"name" : "XYZ",
"ids" : [
"abc.600605b00237d91016cdc38f376bd31d",
"abc.600605b00237d91016cdc38f376cd32f"
]
}
}