colinlaney / animal-tracking

Object tracking with OpenCV in open field behavioral test (overhead view maze)
https://youtu.be/GebcshN4OdE
Creative Commons Zero v1.0 Universal
50 stars 23 forks source link

The program shows me just half of my field #8

Open colinlaney opened 5 years ago

colinlaney commented 5 years ago

When i run the program , it shows me just half of my field ( but I’m using rat in a smaller box) I’ve tried to change it with changing “. frame[:,w-h:w ]” And also I’ve put 1 to HALF_AREA=1hh . I’m using mp4 video in 30 FPS and 1280 to 720. And also I want to count average speed every 20 Seconds. Is it possible to use your method in real-time.? Thank you for answer !

Originally posted by @amirprobuetmir in https://github.com/colinlaney/animal-tracking/issues/1#issuecomment-477704098

colinlaney commented 5 years ago
  1. You are right: disable all cropping of the frame by commenting of frame = frame[:, w-h : w] and check out what you will get.
  2. HALF_AREA has nothing to do with frame visibility, leave it untouched.
  3. Speed. There are two variables within the loop: distance and t – just divide deltas when you need, if you don't want wait my updates.
  4. Real-time out of the box. Not in the current version. But you can replace cv2.VideoCapture(filename) with cv2.VideoCapture(0) and the input will be changed from video file to your webcam.

Please open new issue when you'll run into new problem.

amirprobuetmir commented 5 years ago
  1. disable all cropping of the frame by commenting of frame = frame[:, w-h : w] and check out what you will get - when i did that it gives me errror : [libopenh264 @ 000002430bd46d00] Incorrect library version loaded Could not open codec 'libopenh264': Unspecified error

2.Speed. There are two variables within the loop: distance and t – just divide deltas when you need, if you don't want wait updates. -this what i didnt understand i've tried to name it average= distance / time . but error said that i must to disribe the average i tryed to make it as the distance average = _x = _y = 0 but it does not help.

Real-time out of the box. Not in the current version. But you can replace cv2.VideoCapture(filename) by cv2.VideoCapture(0) and the input will be changed from video file to your webcam. --- when i made that it showed me in preprocessing box my webcam but after i have choosen area it showed me 2 times smaller half version of my rat.mp4 movie in the left side and normal half version and also it gives an error but works : [ WARN:1] terminating async callback

Failed to load OpenH264 library: openh264-1.8.0-win64.dll Please check environment and/or download library: https://github.com/cisco/openh264/releases

[libopenh264 @ 00000242f45b9f40] Incorrect library version loaded

amirprobuetmir commented 5 years ago

and also when i run your code without any chages it works but shows an error: [libopenh264 @ 0000015610afadc0] Incorrect library version loaded Could not open codec 'libopenh264': Unspecified error

colinlaney commented 5 years ago
  1. What do you mean by

it works but shows an error

You mean, the processing runs on UI but you Could not open codec 'libopenh264' on your terminal in the same time? If yes, so what is the problem with the step 1?


  1. May be the problem is not with average but with time variable? There is no time variable, there is t.

  2. but after i have choosen area it showed me 2 times smaller half version of my rat.mp4 movie in the left side and normal half version

It's about rat.mp4 or about the picture from your webcam? If you are observing the replacement the picture from webcam by picture from your movie, then probably you have replaced cv2.VideoCapture(filename) not everywhere.

Anyway such picture is exactly what you will get, because left side shows the selected area on the right side expanded to full size of left half of UI window. The point is to get rid of perspective deformations of the camera. If you don't care about perspective just select full area on the right side and then you'll get the same picture on the left side.

colinlaney commented 5 years ago

and also when i run your code without any chages it works but shows an error: [libopenh264 @ 0000015610afadc0] Incorrect library version loaded Could not open codec 'libopenh264': Unspecified error

First of all try to install H.264 from K-Lite Codec Pack.

amirprobuetmir commented 5 years ago

Yeah , thanks I’ll try . Also I’ve made an experiments with black box and less illumination - and it worked in real time !))but it was not counting time .

pent1162 commented 2 years ago

I comment all of the frame = frame[:, w-h : w] but got an error: imgContour = cv2.add(imgPoints, imgTrack) cv2.error: OpenCV(4.5.5) /Users/runner/work/opencv-python/opencv-python/opencv/modules/core/src/arithm.cpp:650: error: (-209:Sizes of input arguments do not match) The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function 'arithm_op'. My video size is 1960*1280. I print the imgPoints and imgTrack, get (1080, 1080, 3) (1080, 1920, 3).

colinlaney commented 2 years ago

Nothing unexpected: you are trying to add frames of different sizes.

What is your goal? Why do you need to stack together non-squared frames, while the algorithm is supposed to stack square ones? Do you have a rectangular open field?