The way I learned to define it was this:
The opening is the stage of the game in which players develop their pieces, get their king to safety, and attempt to control the center.
It switches to the middle game when players begin to attack each other, and defend.
The end game is when most of the pieces are off of the board. There is no definite number of pieces, but it's usually a safe bet to call it the endgame when each player has three pieces (knights, bishops, rooks, queens) or less.
Hope this helps! thanks
Ok den n00bs