Eris
Eris
CC#
Created by Eris on 9/23/2023 in #help
✅ Can't use Machine Learning Model
Heyo! So I wanted to try out using an AI model to sort some pictures into one of two categories, the app I'm trying to use it in is a Console App in .NET Framework 4.7.2 targeted for x64, I've added a Machine Learning Model (called Stone_Diff), trained it and it works great, but I can't figure out how to use it. I copied the sample code the setup gave me, but it comes up as "The type or namespace name 'Stone_Diff' could not be found" and "The name 'Stone_Diff' does not exist in the current context". Here's the code I'm using:
//Load sample data
var imageBytes = File.ReadAllBytes(@"path-to-file\0.png");
Stone_Diff.ModelInput sampleData = new Stone_Diff.ModelInput()
{
ImageSource = imageBytes,
};

//Load model and predict output
var result = Stone_Diff.Predict(sampleData);
//Load sample data
var imageBytes = File.ReadAllBytes(@"path-to-file\0.png");
Stone_Diff.ModelInput sampleData = new Stone_Diff.ModelInput()
{
ImageSource = imageBytes,
};

//Load model and predict output
var result = Stone_Diff.Predict(sampleData);
Why's it erroring out, do I need to manually add some references or something? If so, I couldn't find how to do it with the normal Add Referenced menu, nor could I find a way to get using Stone_Diff; to work. Thank you for reading!
111 replies
CC#
Created by Eris on 9/7/2023 in #help
❔ How can I start project from another project?
Heyo! So in one solution I have two projects, Project 1 and Project 2. Project 1 is a WinForms app and is the "main" one, and Project 2 is a Console Application, which I've added to Project 1's references. How can I "run" Project 2 from within Project 1? I've googled for a while but I'm not sure how to phrase this. Thanks for reading!
22 replies
CC#
Created by Eris on 8/17/2023 in #help
❔ Form not detecting key presses
Heyo! I can't figure out why this form doesn't take key presses. I'm working in a .NET Windows Forms app, and I have a Form where I want to move a pictureBox using the arrow keys. I've set the form's KeyPreview = true property and set its KeyDown event to my method, tried both in designer and by writing this.Keydown += Form_KeyDown; in code, as well as both simultaneously. However no key press triggers the method. I have double-clicked the Event in the form editor many times to check again whether the Event is linked to the correct method and it definitely is. The method in question:
private void Form_KeyDown(object sender, KeyEventArgs e)
{
MessageBox.Show("here!");
if (e.KeyCode == Keys.Left)
{
zoomReticle.Location = new Point(zoomReticle.Location.X - 1, zoomReticle.Location.Y);
e.SuppressKeyPress = true;
updateReticle();
}
if (e.KeyCode == Keys.Up)
{
zoomReticle.Location = new Point(zoomReticle.Location.X, zoomReticle.Location.Y - 1);
e.SuppressKeyPress = true;
updateReticle();
}
if (e.KeyCode == Keys.Right)
{
zoomReticle.Location = new Point(zoomReticle.Location.X + 1, zoomReticle.Location.Y);
e.SuppressKeyPress = true;
updateReticle();
}
if (e.KeyCode == Keys.Down)
{
zoomReticle.Location = new Point(zoomReticle.Location.X, zoomReticle.Location.Y + 1);
e.SuppressKeyPress = true;
updateReticle();
}
}
private void Form_KeyDown(object sender, KeyEventArgs e)
{
MessageBox.Show("here!");
if (e.KeyCode == Keys.Left)
{
zoomReticle.Location = new Point(zoomReticle.Location.X - 1, zoomReticle.Location.Y);
e.SuppressKeyPress = true;
updateReticle();
}
if (e.KeyCode == Keys.Up)
{
zoomReticle.Location = new Point(zoomReticle.Location.X, zoomReticle.Location.Y - 1);
e.SuppressKeyPress = true;
updateReticle();
}
if (e.KeyCode == Keys.Right)
{
zoomReticle.Location = new Point(zoomReticle.Location.X + 1, zoomReticle.Location.Y);
e.SuppressKeyPress = true;
updateReticle();
}
if (e.KeyCode == Keys.Down)
{
zoomReticle.Location = new Point(zoomReticle.Location.X, zoomReticle.Location.Y + 1);
e.SuppressKeyPress = true;
updateReticle();
}
}
The MessageBox was there for debugging, it never shows up no matter what key is pressed, the pictureBox doesn't move either. I've used this method for detecting keys and it's always worked fine, I have no idea why it doesn't work now sadboihours
16 replies