HuskyLens is an easy-to-use AI machine vision sensor. It is equipped with multiple functions, such as face recognition, object tracking, object recognition, line tracking, color recognition, and tag(QR code) recognition.
By lucadagostino84
#43747
Hi everyone,
I'm having some problems configuring HuskyLens with Raspbery Pi.
I have connected Huskylens to I2C and set up I2C in the chamber.
When I run the example script from the library however it generates an error, where am I going wrong?

this is my code:
Code: Select all
from huskylib import HuskyLensLibrary

camera = HuskyLensLibrary("I2C","",address=0x32)

print("First request a knock: {}".format(camera.knock()))
camera.algorthim("ALGORITHM_FACE_RECOGNITION")

while(true):
    data=camera.blocks()
    x=0
    for i in data:
        x=x+1
        print("Face {} data: {}".format(x,i)) 

This is the error:

First request a knock: Knock Recieved
Traceback (most recent call last):
File "/home/pi/huskycam/test/huskylib.py", line 179, in processReturnData
commandSplit[4][2:4]+commandSplit[4][0:2], 16)
TypeError: int() can't convert non-string with explicit base

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "prova.py", line 6, in <module>
camera.algorthim("ALGORITHM_FACE_RECOGNITION")
File "/home/pi/huskycam/test/huskylib.py", line 387, in algorthim
return self.processReturnData()
File "/home/pi/huskycam/test/huskylib.py", line 217, in processReturnData
self.huskylensSer.timeout=5
AttributeError: 'SMBus' object has no attribute 'timeout'
[email protected]:~/huskycam/test $ python3 prova.py
First request a knock: Knock Recieved
Traceback (most recent call last):
File "/home/pi/huskycam/test/huskylib.py", line 179, in processReturnData
commandSplit[4][2:4]+commandSplit[4][0:2], 16)
TypeError: int() can't convert non-string with explicit base

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "prova.py", line 6, in <module>
camera.algorthim("ALGORITHM_FACE_RECOGNITION")
File "/home/pi/huskycam/test/huskylib.py", line 387, in algorthim
return self.processReturnData()
File "/home/pi/huskycam/test/huskylib.py", line 217, in processReturnData
self.huskylensSer.timeout=5
AttributeError: 'SMBus' object has no attribute 'timeout'


thanks for support

Luca
By klasstaffan
#44261
HuskyLens is pretty easy-to-use. You can change various algorithms by pressing the function button. Click the learning button, HuskyLens starts learning new things. After that, HuskyLens is able to recognize them.
By stevegale54
#44463
I think its an error with the python library when the returned data is null or all zeroes.
I have forked the library and it seems to work, although I am still testing.

The code can be found here
https://github.com/windy54/HUSKYLENSPython.git

It might not be the most elegant fix but it seems to work!

Also I have added a main function, so if you type
python3 huskylib.py it will runa face recogntiion example.

The function hl.blocks() now returns a class rather than list, so an earlier example I tried did not work.

Steve
By polel129
#44512
Hi Steve,

Thank you so much for your library! The I2C connection still has problems with smbus, so I connected Huskylens to the USB port of Raspberry and used the serial connection.

Here's my code for reading block attributes. If the object on the screen is recognized, then an mp3 file is played. My project is for blind people.
Code: Select all
import time
from huskylib import HuskyLensLibrary
import vlc

hl = HuskyLensLibrary("SERIAL", "/dev/ttyUSB0", 3000000)

while True:
    result = hl.requestAll()
    for i in result:
        b_learned = getattr(i,"learned")
        b_id = getattr(i,"ID")
        if b_learned == True:
            media = vlc.MediaPlayer(str(b_id)+".mp3")
            media.play()
            time.sleep(5)
            break

I want to express my disappointment for DFRobot technical support. I first contacted them on March 15, about the problem with the python library and Raspberry. We exchanged a few email messages and they reassured me that they are going to fix it. The last email I had from them was on March 31. Since then, they don't even bother to reply to my messages.

Thanks again Steve!