Ask Your Question

Revision history [back]

Fail to import smbus in OpenCV??

I am a newbie working on a project which requires the use of a PWM driver board (Adafruit PCA9685) and control it through data obtained from openCV. I'm using raspberry pi 2 and OpenCV 2.7 as my platform. Initially, I tested my PWM driver board with the official example code provided by Adafruit, and it worked perfectly. However, when I implant my code into OpenCV, error messages keep popping up.

Traceback (most recent call last):
  File "HSV_servo.py", line 3, in <module>
    from Adafruit_PWM_Servo_Driver import PWM
  File "/home/pi/test/PWM_Servo/Adafruit_PWM_Servo_Driver.py", line 5, in <module>
    from Adafruit_I2C import Adafruit_I2C
  File "/home/pi/Adafruit-Raspberry-Pi-Python-Code/Adafruit_PWM_Servo_Driver/Adafruit_I2C.py", line 3, in <module>
    import smbus
ImportError: No module named smbus

It seems that openCV failed to recognize python-smbus, is there any solution??

My code for reference (not yet complete):

#!/usr/bin/python
from Adafruit_PWM_Servo_Driver import PWM
import time

#import necessary packages
from picamera.array import PiRGBArray
from picamera import PiCamera
import cv2
import numpy as np
import argparse