Hello Tello Pilot!
Join our DJI Tello community & remove this banner.
Sign up

Face tracking with tello and gocv

javaguy

Active member
Joined
May 1, 2018
Messages
29
Reaction score
19
Any reason this could not be expanded to whole body tracking? A face or a body is just an image for the app to recognize, right?
Could be used to track anything, you just need the proper image classifier files for it. The only thing is there may be some difficulty tracking large or far objects because the opencv image window is so small.
 

seahope

New member
Joined
May 30, 2018
Messages
4
Reaction score
5
My Trello arrived today and I have just built the FaceDetect code on my Mac. I did encounter a compilation problem. If anyone else hits this error:
go run facetracking.go

# command-line-arguments

./facetracking.go:118:30: multiple-value gocv.NewMatFromBytes() in single-value context

Change line 118 from:

img := gocv.NewMatFromBytes(frameY, frameX, gocv.MatTypeCV8UC3, buf)

to

img, _ := gocv.NewMatFromBytes(frameY, frameX, gocv.MatTypeCV8UC3, buf)

I haven't actually tried this code yet as I am waiting for my battery to recharge :)

Sorry posted this in the wrong place.
 
Last edited:
  • Like
Reactions: JoeBaldy

seahope

New member
Joined
May 30, 2018
Messages
4
Reaction score
5
All,

I have taken javaguy's code and stripped out the joystick handling code as the bluetooth joystick I bought only works with my phone and not my mac and I don't own any consoles.

As there is no joystick required I have added an additional parameter which is the time before the drone lands. When the drone lands the program continues so you will need to <ctl>C it. I have also written out lots of debug information so I could figure out why it wasn't working. I wondered why the drone only ever moved backwards and realised it was because my baseline position was at the extreme edge of face detection so it would only ever go backwards as I moved towards it :) The code now waits until it detects a face at for my set-up the right distance.

I have uploaded the code to GitHub repo for anyone who wants to see / try it. The algorithm is very simple so best to make sure there is only one face detected ;-)

As for javaguy's original code use at your own risk! I ran this code on my MacBook with the wifi connected to the Trello.

Source code is here: stevef1uk/trello

It was great to have a first program for UAV programming. Thanks to javaguy & deadprogram for all their hard work on this (y)
 

JoeBaldy

Active member
Joined
Apr 28, 2018
Messages
41
Reaction score
9
... I'm blocked ...

C:\Users\Administrator>go get -v github.com/veandco/go-sdl2/sdl_mixer
github.com/veandco/go-sdl2 (download)
package github.com/veandco/go-sdl2/sdl_mixer: cannot find package "github.com/veandco/go-sdl2/sdl_mixer" in any of:
C:\Go\src\github.com\veandco\go-sdl2\sdl_mixer (from $GOROOT)
C:\Users\Administrator\go\src\github.com\veandco\go-sdl2\sdl_mixer (from $GOPATH)

... why ???
... what's wrong ???

... please, help ... thanks
 

JoeBaldy

Active member
Joined
Apr 28, 2018
Messages
41
Reaction score
9
... I'm blocked ...

C:\Users\Administrator>go get -v github.com/veandco/go-sdl2/sdl_mixer
github.com/veandco/go-sdl2 (download)
package github.com/veandco/go-sdl2/sdl_mixer: cannot find package "github.com/veandco/go-sdl2/sdl_mixer" in any of:
C:\Go\src\github.com\veandco\go-sdl2\sdl_mixer (from $GOROOT)
C:\Users\Administrator\go\src\github.com\veandco\go-sdl2\sdl_mixer (from $GOPATH)

... why ???
... what's wrong ???

... please, help ... thanks
I lost all my hopes of running the facial detection of this project. In the absence of any support I am forced to abandon the project ... shame ...

AD MAIORA
 

ianblenke

Member
Joined
Jul 5, 2018
Messages
5
Reaction score
5
I lost all my hopes of running the facial detection of this project. In the absence of any support I am forced to abandon the project ... shame ...

AD MAIORA
I ran into the same problem you did, and it was because they have refactored the go-sdl2 project to use different paths than in the previously mentioned examples.

This one-liner is in my Dockerfile that I use to solve this:

bash -c 'go get -v github.com/veandco/go-sdl2/{sdl,img,mix,ttf}'

which expands to these commands separately:

go get -v github.com/veandco/go-sdl2/sdl
go get -v github.com/veandco/go-sdl2/img
go get -v github.com/veandco/go-sdl2/mix
go get -v github.com/veandco/go-sdl2/ttf
 
  • Like
Reactions: JoeBaldy

JoeBaldy

Active member
Joined
Apr 28, 2018
Messages
41
Reaction score
9
I ran into the same problem you did, and it was because they have refactored the go-sdl2 project to use different paths than in the previously mentioned examples.

This one-liner is in my Dockerfile that I use to solve this:

bash -c 'go get -v github.com/veandco/go-sdl2/{sdl,img,mix,ttf}'

which expands to these commands separately:

go get -v github.com/veandco/go-sdl2/sdl
go get -v github.com/veandco/go-sdl2/img
go get -v github.com/veandco/go-sdl2/mix
go get -v github.com/veandco/go-sdl2/ttf
many thanks for the tip !!!
at least those steps have been successful ... now, given your kind availability, is not that you could give me a tip regarding the following error ???

C:\Users\Administrator\go\src\facetrack>go run facetracking.go proto.txt model
# gocv.io/x/gocv
core.cpp: In function 'void Mat_Size(Mat, IntVector*)':
core.cpp:141:27: error: 'struct cv::MatSize' has no member named 'dims'
int* ids = new int[ms.dims()];
^~~~
core.cpp:143:31: error: 'struct cv::MatSize' has no member named 'dims'
for (size_t i = 0; i < ms.dims(); ++i) {
^~~~
core.cpp:147:22: error: 'struct cv::MatSize' has no member named 'dims'
res->length = ms.dims();
^~~~

... thanks in advance !!!

AD MAIORA
 

ianblenke

Member
Joined
Jul 5, 2018
Messages
5
Reaction score
5
many thanks for the tip !!!
at least those steps have been successful ... now, given your kind availability, is not that you could give me a tip regarding the following error ???

C:\Users\Administrator\go\src\facetrack>go run facetracking.go proto.txt model
# gocv.io/x/gocv
core.cpp: In function 'void Mat_Size(Mat, IntVector*)':
core.cpp:141:27: error: 'struct cv::MatSize' has no member named 'dims'
int* ids = new int[ms.dims()];
^~~~
core.cpp:143:31: error: 'struct cv::MatSize' has no member named 'dims'
for (size_t i = 0; i < ms.dims(); ++i) {
^~~~
core.cpp:147:22: error: 'struct cv::MatSize' has no member named 'dims'
res->length = ms.dims();
^~~~

... thanks in advance !!!

AD MAIORA
I ran into that problem as well. It ended up being the version of OpenCV that I had installed. The fix was to `make install` in the gocv folder. This is the line in my Dockerfile that "fixed' it:

sofwerx/docker-tello-facetrack

I believe the problem here is that the opencv in the debian stretch base image isn't the version that is needed to build things correctly. The gocv project builds its own version of opencv, and doing the `make install` will effectively replace the version of opencv that is used by `go run` with a version that works correctly.

Hope this helps.
 
  • Like
Reactions: JoeBaldy

JoeBaldy

Active member
Joined
Apr 28, 2018
Messages
41
Reaction score
9
I ran into that problem as well. It ended up being the version of OpenCV that I had installed. The fix was to `make install` in the gocv folder. This is the line in my Dockerfile that "fixed' it:

sofwerx/docker-tello-facetrack

I believe the problem here is that the opencv in the debian stretch base image isn't the version that is needed to build things correctly. The gocv project builds its own version of opencv, and doing the `make install` will effectively replace the version of opencv that is used by `go run` with a version that works correctly.

Hope this helps.
... as always, thanks so much, but I'm using Windows 10 x64 ... but, according to you, BLAS and LAPACK are libs / dll that must necessarily be present in the system ???

AD MAIORA
 

ianblenke

Member
Joined
Jul 5, 2018
Messages
5
Reaction score
5
... as always, thanks so much, but I'm using Windows 10 x64 ... but, according to you, BLAS and LAPACK are libs / dll that must necessarily be present in the system ???

AD MAIORA
I didn't stumble across BLAS and LAPACK library problems during my build process. Whatever libraries that gocv needs to build and install are the libraries that you will need under Windows 10.

You may want to install the linux subsystem for Windows 10 as that may make things a good deal easier to build.
 
  • Like
Reactions: JoeBaldy

JoeBaldy

Active member
Joined
Apr 28, 2018
Messages
41
Reaction score
9
I didn't stumble across BLAS and LAPACK library problems during my build process. Whatever libraries that gocv needs to build and install are the libraries that you will need under Windows 10.

You may want to install the linux subsystem for Windows 10 as that may make things a good deal easier to build.
... I take advantage of your enormous kindness and availability asking if you can create a step by step "fool proof" (which I am) to install your package on an istance of Ubuntu on Windows ...

As always, thanks in advance

AD MAIORA
 

ianblenke

Member
Joined
Jul 5, 2018
Messages
5
Reaction score
5
... I take advantage of your enormous kindness and availability asking if you can create a step by step "fool proof" (which I am) to install your package on an istance of Ubuntu on Windows ...

As always, thanks in advance

AD MAIORA
Microsoft's guide to installing the Windows Subsystem for Linux is really the best place I can point you to:

Install the Linux Subsystem on Windows 10

Under the covers, you aren't running a linux kernel, instead the linux userspace runtimes are being executed natively through an ABI compatibility layer, effectively making you think you're running your favorite linux variant without having to run a virtual machine to do so.

We're treading into off-topic conversation here, however.
 
  • Like
Reactions: JoeBaldy

JoeBaldy

Active member
Joined
Apr 28, 2018
Messages
41
Reaction score
9
Microsoft's guide to installing the Windows Subsystem for Linux is really the best place I can point you to:

Install the Linux Subsystem on Windows 10

Under the covers, you aren't running a linux kernel, instead the linux userspace runtimes are being executed natively through an ABI compatibility layer, effectively making you think you're running your favorite linux variant without having to run a virtual machine to do so.

We're treading into off-topic conversation here, however.
... you're right, we are going off-topic ... how and where can we continue this discussion ?

P.S. I've already installed linux subsystem ... I need the subseguent passages ... ;)
 

deadprogram

Well-known member
Joined
Mar 22, 2018
Messages
54
Reaction score
18
Hello, everyone. Please check out the latest versions of Gobot and GoCV. The newest GoCV includes updated installation instructions for OpenCV 3.4.2

Also, the Tello examples have been updated, and also I've added a version of the face tracking Tello based on the cool work from Javaguy.
 
  • Like
Reactions: JoeBaldy

JoeBaldy

Active member
Joined
Apr 28, 2018
Messages
41
Reaction score
9
Hello, everyone. Please check out the latest versions of Gobot and GoCV. The newest GoCV includes updated installation instructions for OpenCV 3.4.2

Also, the Tello examples have been updated, and also I've added a version of the face tracking Tello based on the cool work from Javaguy.
... with the latest versions of Gobot and GoCV all is perfectly working now !!! :):D(y)

... thanks to deadprogram for the tip and to all those who have given me suggestions !!!

AD MAIORA
 

javaguy

Active member
Joined
May 1, 2018
Messages
29
Reaction score
19
Thanks DeadProgram for adding an extension of this to your gobot library.

I'll look into what it takes to make this more user friendly and perhaps turn it into a phone app.
 

New Threads

Members online

Forum statistics

Threads
3,353
Messages
26,111
Members
8,666
Latest member
afrestrepo