0
$\begingroup$

I have a video in MPG format showing a white mouse with a strong black dot on the head moving around on an off-white background, so effectively a black dot moving around on a 2-D plain surface. From this video, I want to generate a set of coordinates that describe the position of the black dot as it varies with time, that is $(X_1, Y_1),...,(X_t,Y_t)$ relative to some arbitrary point on the surface, such as the centre of the image. I also want to create a set of arrays representing a grid across the plain, with $0$s across the grid, except for a $1$ for where the mouse is at time $t$. That is, the motion of the mouse down in a small surface in 3 time steps/frames would be represented by $$ \begin{matrix} 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \end{matrix} $$ $$ \begin{matrix} 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 \end{matrix} $$ $$ \begin{matrix} 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \end{matrix} $$ or $(2,3), (2,2), (2,1)$.

I think the first stage is to somehow convert the video into a set of still images, so effectively split the video into the frames that make it up. I have a mac, and any suggestions on a piece of software to do this would be much appreciated.

The second stage requires some kind of image processing package, but again, I'm not sure what to use, so advice would be much appreciated.

The project I am working on requires the final data (i.e, matrix and coordinate) forms, and isn't that concerned with how I get the data in the first place, so I am looking for simple software packages that lets me get this data. However, if anyone has some code in matlab or python that lets me analyse the still images from scratch, that would be appreciated too.

Thanks!

$\endgroup$
1
$\begingroup$

You can use opencv library with python for image processing.

  1. Use Videocapture object to capture video from video MPG file.
  2. Do cap.read() to read frame by frame.
  3. Convert your frame to grayimage by cvtColor().
  4. Use threshold() function with threshold type-4(threshold with invert option) and with max-binary value as 1. Now you got Mat array with 1 for your mouse with zeroes for background.
  5. Now you can search for 1 in the array and get the coordinates.
$\endgroup$
  • $\begingroup$ That sounds perfect, so thank very much (+1) but with one small problem. My canopy package manager won't connect to the canopy server, so I'm not sure how to install the opencv library. Any ideas? $\endgroup$ – Pablo Nov 8 '16 at 22:48
  • $\begingroup$ I don't use a Mac but I guess this link will be helpful to you How to install opencv on Mac $\endgroup$ – Navin Prashath Nov 9 '16 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.