Fail to import smbus in OpenCV?? [closed]

asked 2015-07-21 21:43:46 -0600

miash gravatar image

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
edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by berak
close date 2015-07-22 00:17:44.114882

Comments

"It seems that openCV failed to recognize python-smbus," - that is wrong, it is your Adafruit_I2C module that wants smbus, not cv2

berak gravatar imageberak ( 2015-07-22 00:18:52 -0600 )edit

Would you kindly guide me how to import smbus for Adafruit_I2C in openCV environment? I can run my code written for Adafruit and opencv seperately, but I failed to import smbus for Adafruit in CV environment.... A little help would be really appreciated!

miash gravatar imagemiash ( 2015-07-22 01:16:21 -0600 )edit

again, unfortunately, all of this is off-topic here

berak gravatar imageberak ( 2015-07-22 03:48:22 -0600 )edit

Sorry to ask again....where should I post this question? Clearly it's related to the working environment of Opencv....

miash gravatar imagemiash ( 2015-07-22 20:18:57 -0600 )edit