Can someone explain the code for me line by line

ok I will see what I can do

It-s a lot of work what you are asking, why instead don’t you start saying what you understand? which line is confusing you?


I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Is about Background subtraction using gaussian Mixture model

why don’t you try to go line by line explaining what it does? when you get stuck you can ask for help on understanding a certain line

am a beginner trying to understand the code. so please can you help me at least with the function defined

your code is no more visible

thank you so much all those who tried,

Please can you help me in any way

please I have sent it as a reply to you

I don’t know python enough, but if you say which specific parts are confusing you someone else will be able to help

1 Like

That doesn’t seem like very good beginner code. Why don’t do pick something easier?

Why do you want to understand this specific code?

I don’t know Python and I didn’t really read the code but it looks like some sort of image processing/analyzes which is always super complex.

1 Like

Just like others mentioned this is a very long code and seems to be a little bit too complicated for the beginner level.
I can understand that your goal is to use python for Data Mining or Machine Learning algorithms but knowing python well-enough is like a foundation that works as a prerequisite to code DM/ML algorithms.

Getting into the code I’m not really familiar with the GMM but if you know the actual formula well enough as well as at least the Python main syntax for loops, functions and condition clause you’d be able to get closer to the meaning behind this code.

On the higher level what seems like it happening is you first initialize your model with number of 3 gaussian models, you then start reordering your models and update values in the updateParam function.
The streamer seems to be the function that generates the final image for you to show the result.

Good Luck :call_me_hand:

thank you so much. it about background subtraction using GMM.
Just that some of the function , I don’t really under
stand how they work

1 Like

yes please, it is about image processing. Can you please explain what the
class MOG(): function does

please am confused with the Class MOG():
reorder and updateParam fucntion

based on your answers I can guide you on learning a couple of things. Those would give you at least the main idea of what’s going on. I strongly suggest you google and research each to find more details.

  1. The zeros function: This is a numpy (np) function that creates an array or matrix of zeros, usually to initialize the array or matrix (please note: we don’t really have a term called matrices here, if the matrix dimension is 2 we have two-dimensional array).

  2. Nested for loops: these are the for loops you typically use to parse and traverse a multi dimensional array. For example the BG_pivot is a two-dimensional array so we need two for loops in order to get to any cell of the two-dimensional array.

  3. self: self is used to refer to the class you’re using, in this case MOG. It’s usually used so that you can use a variable across multiple functions (for example like self.height, self.width ). For knowing why we really need to do such thing you’d need to read more about a concept called ‘scopes’ which is a very important thing to know,; not that hard to grasp though!

Hope these help you get close to what these do.

And Good Luck :call_me_hand:

thank you so much shervinee

1 Like