Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unresolved import in python opencv samples

I am having problem running the opt_flow.py in /opencv/samples/python2. In /samples/python everything is okay. But in python2, there seems something missing.

The python version: 2.7.3 IDE: pyDev in Eclipse

running opt_flow.py from https://github.com/jonmarimba/OpenCVMirror/blob/ff81e19a7a12764c657e2765d69ef166065f5e61/opencv/samples/python2/opt_flow.py

Below are from the code snippet:

    import cv2, cv2.cv as cv
    import video
    from common import anorm2, draw_str
    from time import clock
    ...

and there comes errors..

    Description    Resource  Path                           Location Type
    Unresolved import: video    optical_flow.py /practice/test  line 9  PyDev Problem
    Unresolved import: draw_str optical_flow.py /practice/test  line 10 PyDev Problem
    Unresolved import: anorm2   optical_flow.py /practice/test  line 10 PyDev Problem

which I didn't found any related solution to this error, can anyone help?

like image 942
Chun F Hsu Avatar asked Sep 10 '12 07:09

Chun F Hsu


1 Answers

I had the same problem so here's the answer just to make it clear to others:

The opencv examples import other files in the same folder. The video.py file is in the same place you found the sample you were running. If you copy one of the examples out, you will also need to copy out other files that it imports, including video.py, common.py, and others.

like image 71
Steve Hanov Avatar answered Sep 30 '22 05:09

Steve Hanov