using RealityKit PhotogrammetrySession with bounding box geometry crashes - realitykit

im using the sample code from apple for the photogrammetry session to demonstrate:
https://developer.apple.com/documentation/realitykit/creating_a_photogrammetry_command-line_app
It all works, BUT when I try to add the geometry parameter to it, it crashes/Stops in an internal break point.
The original code looks like:
if let detailSetting = detail {
return PhotogrammetrySession.Request.modelFile(url: outputUrl,
detail: detailSetting)
} else {
As soon as I add a boundary box, the code crashes/stops at an internal breakpoint.
For the demonstration I added the bounding box that got calculated by the session manually
if let detailSetting = detail {
let bx = BoundingBox(min: SIMD3<Float>(-0.5131897, -0.36881575 -0.35893312),
max: SIMD3<Float>(0.5131897, 0.36881575, 0.35893312))
let geom: PhotogrammetrySession.Request.Geometry? =
PhotogrammetrySession.Request.Geometry(
bounds: bx, transform: Transform.identity)
return PhotogrammetrySession.Request.modelFile(url: outputUrl,
detail: detailSetting,
geometry: geom)
} else {
I know I had the bounding box working before, but I don't see why it stopped.
Does anyone know if that is a known problem in a softwareupdate or something else out of my control?
The debugger shows:
The output is unsuspicious:
And the backtrace is
not useful to me.
Any suggestions?
Thank you

It seems to be fixed with Monteray 12.3

Related

"fail to excute createRadialGradient,the provided double value is non-finite" on my canvas animation

I was intending to make a color gradient circle animation with canvas but I got this error "fail to execute createRadialGradient, the provided double value is non-finite" in the console. I am coding this with my MAC but when I copied those code to my windows PC it is just run perfectly. which is really confused me. the following error code would be like:
//...within my circle constructor
this.color = function(){
var grad = ctx.createRadialGradient(this.x,this.y,0,this.x,this.y,this.r);
var colorArray = ['green','red','yellow','blue','purple'];
grad.addColorStop(0,colorArray[Math.floor(Math.random()*colorArray.length)]);
grad.addColorStop(.2,colorArray[Math.floor(Math.random()*colorArray.length)]);
return grad
I just don't think there is any error with my color()function but when I called this with animation in later phase the error just popped out. Is there anyone could help me with this? All the source code could be viewed at https://github.com/mystreie1126/CanvasExperiment/blob/master/Color%20gradient%20Circle%20Animation/colorCircle.html
thanks in advance

Check if exact image in exact location is on screen

I am looking to create a program in Visual Studio (C#) which scans the screen for an exact image in an exact location of the screen. I have seen many discussions which involve algorithms to find a "close" image, but mine will be 100% exact; location, size and all.
I have obtained a png from a section of my screen [Image 1] using this code:
private void button1_Click(object sender, EventArgs e)
{
//Create a new bitmap.
var bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height);
// Create a graphics object from the bitmap.
var gfxScreenshot = Graphics.FromImage(bmpScreenshot);
// Take the screenshot from the upper left corner to the right bottom corner.
gfxScreenshot.CopyFromScreen(1555, 950,
1700, 1010,
Screen.PrimaryScreen.Bounds.Size,
CopyPixelOperation.SourceCopy);
// Save the screenshot to the specified path that the user has chosen.
bmpScreenshot.Save("Screenshot.png");
}
So, basically here is the flowchart of my program on how I want to move forward:
1) create the master png using the above code
2) run loop:
create same screenshot using the same procedure as the master png
compare master png to new screenshot png and if:match then move on otherwise reiterate loop.
I am very new to programming, but I don't believe this is beyond me, given a little guidance. I have written fairly complicated (in my opinion) VBA and Matlab programs. Any help is greatly appreciated.
Thank You,
Sloan
Digging around a bit through Microsoft's documentation, I came up with a rough function that would do something similar to what you want.
https://msdn.microsoft.com/en-us/library/hh191601.aspx
This function offers the chance of getting stuck in an endless loop, so you might consider calling it with a timeout from your main. See here for info on synchronous methods with timeouts:
Monitoring a synchronous method for timeout
From your main, all you'd have to do is see if it returns true.
static int Main(string[] args)
{
if (ImageInLocation(left, right, top, bottom)) {
// do other things
}
return 0;
}
The only thing I'm not entirely sure on is how strict you can be with the ColorDifference. Even if the images are identical, any pixel difference with an entirely non-tolerant ColorDifference will come up false. If you know it should work and it's not, perhaps consider increasing the tolerance. Here's some more info on that:
https://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.uitesting.colordifference.aspx
public bool ImageInLocation(int left, int right, int top, int bottom) {
bool image_found = false;
var masterImage = Image.FromFile("path_to_master");
while (!image_found) {
// screenshot code above, output to "path_to/Screenshot.jpg"
var compImage = Image.FromFile("path_to/Screenshot.jpg");
// note, all zeroes may not be tolerant enough
var color_diff = new ColorDifference(0, 0, 0, 0);
Image diffImage;
image_found = ImageComparer.Compare(masterImage, compImage, color_diff, out diffImage);
}
return true;
}
Good luck! Welcome to the programming community.
Also, if anyone has any suggestions/changes, feel free to edit this. Happy imaging, friends!

Add circle on Bokeh image

I'm working with Bokeh and I want to add a circle on a specific position on my image.
For the moment, I create my image like this :
img = image(image=[data],
x_range=[0, x_range],
y_range=[0, y_range],
x=x,
y=y,
dw=dw,
dh=dh,
tools=TOOLS,
palette=["Greys-9"],
title=title,
plot_width=plot_width,
plot_height=plot_height,
)
circle(x=10,y=10,radius=100,fill_color="#df1c1c",line_color="#df1c1c")
resources = Resources("inline")
plot_script, plot_div = components(img, resources)
html_script = encode_utf8(plot_script)
html_div = encode_utf8(plot_div)
hold()
figure()
return html_script, html_div
and send this to my HTML page.
The problem is that the circle is not on the final display. Maybe on background ? I don't know...
I tryed add function, add_glyph function, add_layout... None of these are functionnal!
Thanks for helping guys
The above code did not work due to a bug in Bokeh. However, the bug has since been fixed, and that code and code similar to it will function as expected.

How to display Images in a wxListCtrl (multicolumn report style)

I already managed to create wxListCtrls with either icons or multicolumn text like this
Picture of two wxListCtrls
Now I'd like to add an icon to each line of the text list on the left. I thought this should be possible as typical wxWidgets applications like code::blocks and wxSmith often diplay icons in list/tree views (resource browser window) and even in tabs of notebooks (compiler log window).
So how can I create something like this? (Everybody knows Windows Explorer)
Picture of Explorer Window with icons
I tried this...
SetImageList (ToolImages, wxIMAGE_LIST_NORMAL);
InsertColumn (0, "Icon");
SetColumnWidth (0, 40);
...
for (int i=0; i<5; i++)
{
InsertItem (i, i);
SetItemColumnImage (i, 0, i);
SetItem (i, 1, IntToStr (i+1));
...
But as you can see, only the text gets displayd, the image column is blank. Is it possible at all to mix text and images in report mode? If not, what other wxControl class can I use to get the desired result?
Many Thanks in advance.
Yes, it is possible, and the listctrl sample shows how to do it, in particular see MyFrame::InitWithReportItems() function. The only difference with your code seems to be that you use a different InsertItem() overload, so perhaps you should use InsertItem(i, "") instead.
Also check that your image list does have the 5 icons in it.
More generally, trying to reduce the differences between your code and the (working) sample will almost always quickly find the problem.
Thanks, VZ, but I found out that it's not the InsertItem() but the SetImageList(). My image list was correct, but the "which" parameter wasn't. Replacing wxIMAGE_LIST_NORMAL by wxIMAGE_LIST_SMALL fixes the problem! I thought "SMALL" was only meant for the SMALL_ICON mode and that "NORMAL" should be the default. But yes, that makes sense, normal icons are big and don't fit in the text display. Would be nice if the documentation had told us that before long trial and error...
This is a simple example for SMALL ICONIC VIEW USING WXLISTCTRL .Please place this code inside the class declaration.I did it in Frame based Windows Application using CODE BLOCKS.It will be useful to you.
wxImageList *il=new wxImageList(32,32,false,0);
wxImageList *i2=new wxImageList(32,32,false,0);
wxDir dir(wxGetCwd());
wxDir dir1(wxGetCwd());
if ( !dir.IsOpened() )
{
// deal with the error here - wxDir would already log an error message
// explaining the exact reason of the failure
return;
}
if ( !dir1.IsOpened() )
{
// deal with the error here - wxDir would already log an error message
// explaining the exact reason of the failure
return;
}
puts("Enumerating object files in current directory:");
wxString path, filename, dirstring,filename1, dirstring1, img,imgPath,path1,img1,imgPath1;
int i=0;
path=wxT("C:\\testing\\splitterwindow\\set\\devices");
path1=wxT("C:\\testing\\splitterwindow\\set\\actions");
img=wxT("C:\\testing\\splitterwindow\\set\\devices\\");
img1=wxT("C:\\testing\\splitterwindow\\set\\actions\\");
bool cont=dir.Open(path);
bool cont1=dir1.Open(path1);
cont = dir.GetFirst(&filename, wxEmptyString, wxDIR_DEFAULT);
dirstring.Append(filename.c_str());
cont1 = dir1.GetFirst(&filename1, wxEmptyString, wxDIR_DEFAULT);
dirstring1.Append(filename1.c_str());
while ( cont )
{
imgPath.clear();
cont = dir.GetNext(&filename);
dirstring.Append(filename.c_str());
// Consturct the imagepath
imgPath.Append(img.c_str());
imgPath.Append(filename.c_str());
//Now, add the images to the imagelist
il->Add(wxBitmap(wxImage(imgPath.c_str())));
i++;
}
while ( cont1 )
{
imgPath1.clear();
cont1 = dir1.GetNext(&filename1);
dirstring1.Append(filename1.c_str());
// Consturct the imagepath
imgPath1.Append(img1.c_str());
imgPath1.Append(filename1.c_str());
//Now, add the images to the imagelist
i2->Add(wxBitmap(wxImage(imgPath1.c_str())));
i++;
}
//assigning the imagelist to listctrl
ListCtrl1->AssignImageList(il, wxIMAGE_LIST_SMALL);
ListCtrl3->AssignImageList(i2, wxIMAGE_LIST_SMALL);
for(int j=0;j < il->GetImageCount()-1;j++)
{
wxListItem itemCol;
itemCol.SetId(j);
itemCol.SetImage(j);
itemCol.SetAlign(wxLIST_FORMAT_LEFT);
ListCtrl1->InsertItem(itemCol);
}
for(int k=0;k < i2->GetImageCount()-1;k++)
{
wxListItem itemCol1;
itemCol1.SetId(k);
itemCol1.SetImage(k);
itemCol1.SetAlign(wxLIST_FORMAT_LEFT);
ListCtrl3->InsertItem(itemCol1);
}
`

jsplumb library getconnection function is not returning values

Hi all I am working in JS plumb library for making connections.I am stuck at one point and need help from experts.
Here is my scenario.
I have many connections and what I want is that when I click on one connection a certain label appears on it to show that it is selected.When I click one some other connection previously clicked connection disappears and new connection get selected.
What I have done so far is that
jsPlumbInst.bind('click', function(c) {
c.showOverlay('selected');
var previously_active = jsPlumbInst.getConnections({scope:"active"});//this function not returning me values
if(previously_active.length != 0) {
/*So never go in this statement*/
previously_active[0].hideOverlay('selected');
previously_active.scope("jsPlumb_DefaultScope");
}
c.scope = "active";
});
Here the problem is that my connection scope is set to "active"
jsPlumbInst.getConnections({scope:"active"})
is not returning anything.
So can any one kindly guide me that whether I am doing right?
Or is there any other way to achieve this?
var sourcecon = jsPlumb.getConnections({source: e}) ;
for(i=0; i<sourcecon.length; i++)
{
var target = getName(sourcecon[i].targetId) ;
var source = getName(sourcecon[i].sourceId) ;
removefrommatrix(source, target,sourcecon[i].sourceId,sourcecon[i].targetId) ;
}
This is code snippet which I am using. It works fine. Your code looks fine except just one difference that you have used jsPlumbInst rather than jsPlumb. I guess that could be the problem. For me its like static class in Java.Not sure about that. But try and see if it could help you.Seems like I am almost a year late in replying. All the best :-)

Resources