Scripts to see what...
 
Notifications
Clear all

Scripts to see what Q.bo sees and when/which faces are detected

17 Posts
7 Users
9 Reactions
3,345 Views
chrisbuy
(@chrisbuy)
Member
Joined: 6 years ago
Posts: 71
Topic starter  

For those interested to go deeper in what Q.bo actually sees or how the face detection works, I've written a small script that will show you a realtime video feed from his connected eye.

  1. Connect to Q.bo using VNC
  2. Copy the attached file Qbo_webcam.py to the /home/pi/ directory
  3. Press Ctrl+Alt+T to open a terminal
  4. Enter
    sudo pkill python
    sudo pkill chromium
  5. Enter
    python Qbo_webcam.py

A window appears named 'Video' showing what Q.bo actually realtime sees and where he detects faces. Green rectangles in the shown video window are detected frontal faces, blue rectangles in the shown video are detected profile faces. Exit by pressing 'q'.

This topic was modified 6 years ago 4 times by chrisbuy

--
Christian Buysschaert
Leuven - Belgium
Email christian.buysschaert@gmail.com


   
Quote
Qbo Robot
(@nonogrub)
Member Admin
Joined: 8 years ago
Posts: 185
 
Posted by: chrisbuy

For those interested to go deeper in what Q.bo actually sees or how the face detection works, I've written a small script that will show you a realtime video feed from his connected eye.

  1. Connect to Q.bo using VNC
  2. Copy the attached file Qbo_webcam.py to the /home/pi/ directory
  3. Press Ctrl+Alt+T to open a terminal
  4. Enter
    sudo pkill python
    sudo pkill chromium
  5. Enter
    python Qbo_webcam.py

A window appears named 'Video' showing what Q.bo actually realtime sees and where he detects faces. Green rectangles in the shown video window are detected frontal faces, blue rectangles in the shown video are detected profile faces. Exit by pressing 'q'.

Got it!!! we will include into the next OpenQbo version!!!

Good Job Chris!


   
ReplyQuote
chrisbuy
(@chrisbuy)
Member
Joined: 6 years ago
Posts: 71
Topic starter  

There is more to come... I've rewritten the entire vision aspect of Q.bo using a tracker to be much more efficient. I had to recompile OpenCV on the Raspberry Pi so I am now finding a way to simplify this process somewhat (a compilation of OpenCV took Q.bo all night long!).

I am using the same HAAR cascades but with a CSRT tracker (although the KCF and MOSSE are faster but less accurate). I experimented also with DLIB as tracker (which I might switch to as well). 

(Later I'll add face detection in PiFaceFast.py which seemed to have been removed?! I guess too slow... I know why there is interest in switching to a different more powerful board. ;-) )

--
Christian Buysschaert
Leuven - Belgium
Email christian.buysschaert@gmail.com


   
ReplyQuote
(@sheldong1225)
Active Member
Joined: 6 years ago
Posts: 11
 

This is what I get "

/home/pi/Qbo_webcam.py ======================

Traceback (most recent call last):
File "/home/pi/Qbo_webcam.py", line 40, in <module>
webcam = cv2.VideoCapture(int(config['camera'])) # Get ready to start getting images from the webcam
TypeError: 'NoneType' object has no attribute '__getitem__' "


   
ReplyQuote
chrisbuy
(@chrisbuy)
Member
Joined: 6 years ago
Posts: 71
Topic starter  

I am assuming the config['camera'] does not return a value.

Check /opt/qbo/config.yml for a line with...

camera: '0'

Or create a file with at least that line...

--
Christian Buysschaert
Leuven - Belgium
Email christian.buysschaert@gmail.com


   
ReplyQuote
(@romeo)
Member
Joined: 6 years ago
Posts: 76
 

Chrisbuy, I'm sorry, but in my configuration the / opt / qbo / directory is missing. The config.yml file is located in the / Documents / configQbo_GTK / ... directory. I modified your program and also in my case it returns error in line 40 ... "camera".


   
ReplyQuote
(@romeo)
Member
Joined: 6 years ago
Posts: 76
 

Chrisbuy, I'm sorry, but in my configuration the / opt / qbo / directory is missing. The config.yml file is located in the / Documents / configQbo_GTK / ... directory. I modified your program and also in my case it returns error in line 40 ... "camera".


   
ReplyQuote
(@sheldong1225)
Active Member
Joined: 6 years ago
Posts: 11
 
Posted by: romeo

Chrisbuy, I'm sorry, but in my configuration the / opt / qbo / directory is missing. The config.yml file is located in the / Documents / configQbo_GTK / ... directory. I modified your program and also in my case it returns error in line 40 ... "camera".

Hi romeo. I had the same issue untill I downloaded OpenQbo v3.0. which is located here. It tells you how to download it. 

[edited] https://gitlab.c...........   [edited]

 

Install
To install the QBO software you will need a clean Raspbian image running on the Raspberry Pi 3 in your QBO robot.
Download latest version of Raspbian from: https://www.raspberrypi.org/downloads/raspbian/
Before installing the QBO Software it is necessary that you activate the SERIAL interface. To activate the serial runs in the terminal execute the following command:
$ sudo raspi-config
Select option 5 'Interfacing Options' and then option P6 'Serial'. Finally, indicate the option 'Yes' to confirm the activation of the Serial port.
Once finished, restart the raspberry pi before continuing with the following steps. You can execute the following command to restart:
$ sudo reboot
Now, execute the following commands in terminal and the QBO system will be installed automatically. If any action is necessary, the installer will indicate it.
$ wget https://gitlab.com/thecorpora/QBO/raw/master/scripts/QBO_Installer.sh
$ chmod +x QBO_Installer.sh
$ sudo ./QBO_Installer.sh install # Add 'develop' if you prefer to install QBO software the development repositories. (Not recommended)
Once the Qbo installation is completed the system will restart and the QBO robot will be ready


   
ReplyQuote
(@sheldong1225)
Active Member
Joined: 6 years ago
Posts: 11
 
Posted by: chrisbuy

I am assuming the config['camera'] does not return a value.

Check /opt/qbo/config.yml for a line with...

camera: '0'

Or create a file with at least that line...

So it does say "distro: standalone, language: english, microphoneGain: 100, camera: 0, servoSpeed: 100, tokenAPIai: , gassistant_proyectid: , dialogflowv2_projectid: , startWith: interactive-dialogflow, volume: 100 }"

I had to reset qbo after that I had much success with some previous problems with it. After repeating all these steps this is the new error I get

libv4l2: error setting pixformat: Device or resource busy
HIGHGUI ERROR: libv4l unable to ioctl S_FMT
libv4l2: error setting pixformat: Device or resource busy
libv4l1: error setting pixformat: Device or resource busy
HIGHGUI ERROR: libv4l unable to ioctl VIDIOCSPICT

OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /build/opencv-U1UwfN/opencv-2.4.9.1+dfsg1/modules/imgproc/src/color.cpp, line 3737
Traceback (most recent call last):
File "Qbo_webcam.py", line 66, in <module>
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.error: /build/opencv-U1UwfN/opencv-2.4.9.1+dfsg1/modules/imgproc/src/color.cpp:3737: error: (-215) scn == 3 || scn == 4 in function cvtColor

When I run it with Thonny I get this error


File "/home/pi/Qbo_webcam.py", line 60
t_ini = time.time()
^
SyntaxError: inconsistent use of tabs and spaces in indentation





When I remove the extra tab I this:

Traceback (most recent call last):
File "/home/pi/Qbo_webcam.py", line 26, in <module>
import yaml
ImportError: No module named 'yaml'



   
ReplyQuote
(@sheldong1225)
Active Member
Joined: 6 years ago
Posts: 11
 

Actually, I didn't kill python. After I killed it, it worked!

This post was modified 6 years ago by SheldonG1225

   
ReplyQuote
Niko
 Niko
(@niko)
Eminent Member
Joined: 6 years ago
Posts: 39
 
Posted by: SheldonG1225
Posted by: romeo

Chrisbuy, I'm sorry, but in my configuration the / opt / qbo / directory is missing. The config.yml file is located in the / Documents / configQbo_GTK / ... directory. I modified your program and also in my case it returns error in line 40 ... "camera".

Hi romeo. I had the same issue untill I downloaded OpenQbo v3.0. which is located here. It tells you how to download it. [edited]  https://gitlab.c...........    [edited]

 

Install
To install the QBO software you will need a clean Raspbian image running on the Raspberry Pi 3 in your QBO robot.
Download latest version of Raspbian from: https://www.raspberrypi.org/downloads/raspbian/
Before installing the QBO Software it is necessary that you activate the SERIAL interface. To activate the serial runs in the terminal execute the following command:
$ sudo raspi-config
Select option 5 'Interfacing Options' and then option P6 'Serial'. Finally, indicate the option 'Yes' to confirm the activation of the Serial port.
Once finished, restart the raspberry pi before continuing with the following steps. You can execute the following command to restart:
$ sudo reboot
Now, execute the following commands in terminal and the QBO system will be installed automatically. If any action is necessary, the installer will indicate it.
$ wget https://gitlab.com/thecorpora/QBO/raw/master/scripts/QBO_Installer.sh
$ chmod +x QBO_Installer.sh
$ sudo ./QBO_Installer.sh install # Add 'develop' if you prefer to install QBO software the development repositories. (Not recommended)
Once the Qbo installation is completed the system will restart and the QBO robot will be ready

I thought that this new version was not public ;)


   
ReplyQuote
(@sheldong1225)
Active Member
Joined: 6 years ago
Posts: 11
 

It may not be v3.0. I just copied and paste chrisbuy link above. In that it says 

#!/usr/bin/env python2 ############################################################### # Qbo_webcam.py # # Based upon "Face Detection in Python Using a Webcam" # ( https://realpython.com/face-detection-in-python-using-a-webcam/) # and "OpenQbo v3.0" ( https://gitlab.com/thecorpora/QBO) # # 1. Connect to Q.bo using VNC # 2. Copy this file Qbo_webcam.py to the /home/pi/ directory # 3. Press Ctrl+Alt+T to open a terminal # 4. Enter # sudo pkill python # sudo pkill chromium # 5. Enter # python Qbo_webcam.py # # Press 'q' to quit. # # Visual aid: # Green rectangles are detected frontal faces # Blue rectangles are detected profile faces

After looking around in the Qbo getlab link. I found it is v1.0. Weird. 

https://gitlab.com/thecorpora/QBO/raw/master/scripts/QBO_Installer.sh

 

This post was modified 6 years ago by SheldonG1225

   
ReplyQuote
(@romeo)
Member
Joined: 6 years ago
Posts: 76
 

thanks a lot, I've tried the scripts and it works,but I realized that I have a long way to go ...


   
ReplyQuote
(@romeo)
Member
Joined: 6 years ago
Posts: 76
 

I do not make any rectangle unfortunately ....


   
ReplyQuote
(@greybeard81)
Eminent Member
Joined: 6 years ago
Posts: 20
 

I'm having difficulty in getting the face recognition to work.  

python Qbo_webcam.py
Traceback (most recent call last):
File "Qbo_webcam.py", line 37, in <module>
config = yaml.safe_load(open("/opt/qbo/config.yml"))
IOError: [Errno 2] No such file or directory: '/opt/qbo/config.yml'

How can I check for the version of QBO that is installed?  I'm running python 2.7.13.

I will start fresh with a virgin 64G memory and start anew. Load OpenQbo v-3. Should I load python 3?  What version of CV is good?

HELP!


   
ReplyQuote
Page 1 / 2
Share: