|
"Motion" is when the previous frame (picture) is not the same as the current frame.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Correct, so in theory it could work since the picturebox is being replaced with a new layer/frame ever second that timer draws a new bitmap image?
I have a picture box that draws the recording of my desktop
private void tmrImageUpdate_Tick(object sender, EventArgs e)
{
var img = new Bitmap(this.Height, this.Width);
var grph = Graphics.FromImage(img);
grph.CopyFromScreen((Cursor.Position.X-(pbImageRelay.Height/2)),(Cursor.Position.Y-(pbImageRelay.Width / 2)), 0, 0, img.Size);
pbImageRelay.Image = img;
}
private void Form1_Load(object sender, EventArgs e)
{
Rectangle resolution = Screen.PrimaryScreen.Bounds;
tmrImageUpdate.Tick += tmrImageUpdate_Tick;
tmrImageUpdate.Enabled = true;
tmrImageUpdate.Start();
}
I am trying to detect the motion in say a video player from the desktop, but within the picture box that is viewing on my desktop. Like a picture in a picture on a TV screen, except on PC.
|
|
|
|
|
Basically, you want "screen copy" the image you just loaded and check that for motion. Something you could accomplish by just focusing on the original images. Okaaay.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
"Okaaay" like you understand my request? Or "Okaaay" like you're being a pompous-dick right now? I mean, I'll understand if you don't know the answer to the question, it's OK to not know everything. But, if you don't know, save me the ridicule and move on, your forum-troll level of insecurity is not required in this thread.
Not everyone who comes in here is on your level, in fact majority of the people that come in here are have some level of knowledge in IT that doesn't equate to your standard of knowledge. That is why I am here, either help or don't help.
Had you in fact read the thread, you would know that nothing of a 'still image' was mentioned, after all Videos are just layered images. Since my picturebox is technically showing a video of my desktop, rather than using Video File Writer is it possible to put these layers into a MemoryStream read it from there?
modified 20-Dec-20 19:06pm.
|
|
|
|
|
The "picture box" shows an "image"; i.e. a "still".
The "media element" can show "videos"; a series of frames (i.e. more than one "still").
Your picture box is not "technically" showing a video, since by definition, one image does not a video make.
Taking screen captures, still amounts to a bunch of "stills". With varying "frame rates".
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
I've found a potential solution in replicating what I am looking for by using Accord VideoFileWrite to write the sequence of frames that bitmap creates, using the PictureBox as a "previewer" to show the height/width of what is being recorded. Is it possible to write VideoFileWrite into a memorystream and use AForges motion detection to read the memorystream or a buffer within the specific moment , rather than the read a file thats been written to the computer.
Example Illustration
|
|
|
|
|
You would need multiple threads:
1) one to capture and "buffer"
2) another to handle the "stills" (picture box ui thread) from a concurrent queue
3) another to handle the recording (async file writes)
A "movie" is about 30 frames per seconds (fps); virtual reality needs to run at least at 90 fps or it causes "motion sickness"; "best" is 120 fps.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Hi,
I use SQL Server 2019. I have created a simple database in SQL Server and made a connection in C# (Visual Studio 2019) with that SQL database. I can read and write information on that SQL database using C#. My problem is that my final application wouldn't have access to the SQL Server because it is in my PC and connects using my windows user/pass. How can I make my database dynamic so my users can access it?
|
|
|
|
|
You connect to a sql db using a connection string. Somewhere in your code or web.config or app.config (depending on what type of project you have) is a connection string which tells the code how to connect to the sql database.
You can either put the database somewhere everyone has access to and update your connection string to point to it or you can expose your database on the network, which it might already be.
|
|
|
|
|
Google "sql server allow remote connections"
|
|
|
|
|
I' ve a ComboBox with Three Items in main Form and a button make another form.show so in the second form i am asking about the selected item in the combox and switch it in 3 cases but i ve an error said nullReference the item is null even i select one item from the Combox ( "Tete", "Doublette", "Triplette")
Thank you for Your Help
|
|
|
|
|
Without seeing the relevant code, it's impossible to tell you anything useful beyond something is null and you're trying to use a property or call a method on it.
|
|
|
|
|
|
A "selected item" is not "valid" unless the .SelectedIndex is > -1 (i.e. >= 0);
A "list control" can have items, but the SelectedIndex says whether or not it is actually "pointing" at something.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
The Form is a container for controls, so you cannot access it directly from another form/class especially when controls have private modifiers. Using access modifiers may still cause some issues. Its better to access the control using Controls class.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnStart_Click(object sender, EventArgs e)
{
comboBox1.Items.Add("Combo Item");
}
}
public class GetComboItem
{
public GetComboItem()
{
ComboBox cmbItm = Application.OpenForms["Form1"].Controls.Find("comboBox1", true)[0] as ComboBox;
MessageBox.Show(cmbItm.Text);
}
}
|
|
|
|
|
Eventually I decided to start with the functional concept and installed the LanguageExt library (see GitHub - louthy/language-ext: C# functional language extensions - a base class library for functional programming[^] ). In our code base, there is a class which is full of bool TryGet(some parameters, out T result) functions - I want to change them to Option<T> TryGet(some parameters) .
But then, things start to look ugly at a different level. E.g.
List<PointF> result = new List<PointF>();
...
foreach (IIntersectionInfo intersection in intersections)
{
Option<PointF> angle = m_Geometry.TryGetAnglesForPosition(intersectionPoint, _name);
if (angle.IsNone)
{
Logger.LogWarning(Name, $"Cannot determine angle for position '{intersectionPoint}' corresponding to pixel '{pixel}'.");
}
else
{
result.Add(angle.IfNone(PointF.Empty));
}
} There are two kinds of ugliness:
- I have to use the IfNone(PointF.Empty) clause even when angle is guaranteed to be Some there.
- I do not know how to get rid of the foreach in this situation.
How can the code become clean?
Oh sanctissimi Wilhelmus, Theodorus, et Fredericus!
|
|
|
|
|
If you didn't want to log the failures, it could be as simple as:
m_Geometry.TryGetAnglesForPosition(intersectionPoint, _name).IfSome(result.Add); Otherwise, something like this should work:
m_Geometry.TryGetAnglesForPosition(intersectionPoint, _name).Match(
point => result.Add(point),
() => Logger.LogWarning(Name, $"Cannot determine angle for position '{intersectionPoint}' corresponding to pixel '{pixel}'.")); There's also the C# 8 property patterns:
if (m_Geometry.TryGetAnglesForPosition(intersectionPoint, _name) is { IsSome: true } angle)
{
angle.IfSome(result.Add);
}
else
{
Logger.LogWarning(Name, $"Cannot determine angle for position '{intersectionPoint}' corresponding to pixel '{pixel}'.");
} Or you could define a deconstructor as an extension method:
public static class OptionTExtensions
{
public static void Deconstruct<T>(this Option<T> option, bool isSome, T value)
{
isSome = option.IsSome;
value = isSome ? (T)option : default;
}
}
...
var (isSome, point) = m_Geometry.TryGetAnglesForPosition(intersectionPoint, _name);
if (isSome)
{
result.Add(point);
}
else
{
Logger.LogWarning(Name, $"Cannot determine angle for position '{intersectionPoint}' corresponding to pixel '{pixel}'.");
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks, that was the major step for this issue.
Afterwards, I could figure out the
var tmp = intersections.Map(_intersection => m_Geometry.TryGet...ToList() monstrosity abolishing the foreach(... intersections) .
Functional programming feels odd when trying it for the first time.
Oh sanctissimi Wilhelmus, Theodorus, et Fredericus!
|
|
|
|
|
Develop a Window Form Application in C# to fulfill the functionality of given below form. Functionality of each button is explained below.
i) Add Employee button will add new employee in DB with unique ID.
ii) Delete and Update Employee will be on the basis of employee ID.
iii) Retrieve All Employee button will retrieve all employees from DB table and populate into grid view control.
iv) Update Employee will update the existing employee; it Search employee on the basis of its ID.
Apply Exception handling in the code and Before the Employee Record is Saved to Database, apply the following Data Validation Checks
1. ID should be distinct and it should not be duplicated in the Table
2. ID, Name, Designation and Salary should not be null
3. ID and Salary should be non-negative, greater than Zero and Positive Values
4. Name and Designation Length should be greater than 6 Characters and Name should not contain any Digit (0-9)
5. Before any DML Statement is executed (Insert Into, Update or Delete), Ask User using MessageBox whether He/She really want to Add / Update / Delete the Record. When user press the OK button on the MessageBox then Record DML statement should be executed.
|
|
|
|
|
No.
Nobody here is going to do your homework for you.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.
So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Okay. I've done that. What now?
|
|
|
|
|
Email it to his teacher to save him the effort?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
Sort of like poking a stick into a hole and seeing if something will grab onto it. I like picturing grizzly bears.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|