STVIR / pysot

SenseTime Research platform for single object tracking, implementing algorithms like SiamRPN and SiamMask.
Apache License 2.0
4.44k stars 1.11k forks source link

CompileError: toolkit/utils/region.pyx #602

Closed al1can closed 1 year ago

al1can commented 1 year ago

Hi everybody, I'm having a problem with building region.c. I followed the instructions in INSTALL.md and when I ran python setup.py build_ext --inplace I'm getting the following in the terminal. Had the same results when I do bash install.sh too. I tried it both in Windows 11 and Ubuntu 22.04 in Virtualbox. I'm using miniconda3.

Thanks in advance.

Compiling toolkit/utils/region.pyx because it changed.
[1/1] Cythonizing toolkit/utils/region.pyx
/home/vboxuser/miniconda3/envs/pysot/lib/python3.7/site-packages/Cython/Compiler/Main.py:381: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /home/vboxuser/Desktop/pysot/toolkit/utils/region.pyx
  tree = Parsing.p_module(s, pxd, full_module_name)

Error compiling Cython file:
------------------------------------------------------------
...

from libc.stdlib cimport malloc, free
from libc.stdio cimport sprintf
from libc.string cimport strlen

cimport c_region
        ^
------------------------------------------------------------

toolkit/utils/region.pyx:11:8: 'c_region.pxd' not found

Error compiling Cython file:
------------------------------------------------------------
...
    RECTANGEL
    POLYGON
    MASK

cdef class RegionBounds:
    cdef c_region.region_bounds* _c_region_bounds
         ^
------------------------------------------------------------

toolkit/utils/region.pyx:21:9: 'region_bounds' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
        self._c_region_bounds.bottom = bottom
        self._c_region_bounds.left = left
        self._c_region_bounds.right = right

cdef class Rectangle:
    cdef c_region.region_rectangle* _c_region_rectangle
         ^
------------------------------------------------------------

toolkit/utils/region.pyx:58:9: 'region_rectangle' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
                self._c_region_rectangle.y,
                self._c_region_rectangle.width,
                self._c_region_rectangle.height)

cdef class Polygon:
    cdef c_region.region_polygon* _c_region_polygon
         ^
------------------------------------------------------------

toolkit/utils/region.pyx:99:9: 'region_polygon' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
    else:
        pno_bounds = RegionBounds(-float("inf"), float("inf"),
                                  -float("inf"), float("inf"))
    cdef float only1 = 0
    cdef float only2 = 0
    cdef c_region.region_polygon* c_polygon1 = polygon1_._c_region_polygon
         ^
------------------------------------------------------------

toolkit/utils/region.pyx:182:9: 'region_polygon' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
        pno_bounds = RegionBounds(-float("inf"), float("inf"),
                                  -float("inf"), float("inf"))
    cdef float only1 = 0
    cdef float only2 = 0
    cdef c_region.region_polygon* c_polygon1 = polygon1_._c_region_polygon
    cdef c_region.region_polygon* c_polygon2 = polygon2_._c_region_polygon
         ^
------------------------------------------------------------

toolkit/utils/region.pyx:183:9: 'region_polygon' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
                                  -float("inf"), float("inf"))
    cdef float only1 = 0
    cdef float only2 = 0
    cdef c_region.region_polygon* c_polygon1 = polygon1_._c_region_polygon
    cdef c_region.region_polygon* c_polygon2 = polygon2_._c_region_polygon
    cdef c_region.region_bounds no_bounds = pno_bounds._c_region_bounds[0] # deference
         ^
------------------------------------------------------------

toolkit/utils/region.pyx:184:9: 'region_bounds' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...

cdef class RegionBounds:
    cdef c_region.region_bounds* _c_region_bounds

    def _cinit_(self):
        self._c_region_bounds = <c_region.region_bounds*>malloc(
                                 ^
------------------------------------------------------------

toolkit/utils/region.pyx:24:33: 'region_bounds' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
cdef class RegionBounds:
    cdef c_region.region_bounds* _c_region_bounds

    def _cinit_(self):
        self._c_region_bounds = <c_region.region_bounds*>malloc(
                sizeof(c_region.region_bounds))
                                ^
------------------------------------------------------------

toolkit/utils/region.pyx:25:32: cimported module has no attribute 'region_bounds'

Error compiling Cython file:
------------------------------------------------------------
...

cdef class Rectangle:
    cdef c_region.region_rectangle* _c_region_rectangle

    def _cinit_(self):
        self._c_region_rectangle = <c_region.region_rectangle*>malloc(
                                    ^
------------------------------------------------------------

toolkit/utils/region.pyx:61:36: 'region_rectangle' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
cdef class Rectangle:
    cdef c_region.region_rectangle* _c_region_rectangle

    def _cinit_(self):
        self._c_region_rectangle = <c_region.region_rectangle*>malloc(
                sizeof(c_region.region_rectangle))
                                ^
------------------------------------------------------------

toolkit/utils/region.pyx:62:32: cimported module has no attribute 'region_rectangle'

Error compiling Cython file:
------------------------------------------------------------
...
        args:
            points: tuple of point
            points = ((1, 1), (10, 10))
        """
        num = len(points) // 2
        self._c_region_polygon = <c_region.region_polygon*>malloc(
                                  ^
------------------------------------------------------------

toolkit/utils/region.pyx:108:34: 'region_polygon' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
            points: tuple of point
            points = ((1, 1), (10, 10))
        """
        num = len(points) // 2
        self._c_region_polygon = <c_region.region_polygon*>malloc(
                sizeof(c_region.region_polygon))
                                ^
------------------------------------------------------------

toolkit/utils/region.pyx:109:32: cimported module has no attribute 'region_polygon'

Error compiling Cython file:
------------------------------------------------------------
...
                sizeof(c_region.region_polygon))
        if not self._c_region_polygon:
            self._c_region_polygon = NULL
            raise MemoryError()
        self._c_region_polygon.count = num
        self._c_region_polygon.x = <float*>malloc(sizeof(float) * num)
                                   ^
------------------------------------------------------------

toolkit/utils/region.pyx:114:35: Cannot convert 'float *' to Python object

Error compiling Cython file:
------------------------------------------------------------
...
            raise MemoryError()
        self._c_region_polygon.count = num
        self._c_region_polygon.x = <float*>malloc(sizeof(float) * num)
        if not self._c_region_polygon.x:
            raise MemoryError()
        self._c_region_polygon.y = <float*>malloc(sizeof(float) * num)
                                   ^
------------------------------------------------------------

toolkit/utils/region.pyx:117:35: Cannot convert 'float *' to Python object

Error compiling Cython file:
------------------------------------------------------------
...
            self._c_region_polygon.x[i] = points[i*2]
            self._c_region_polygon.y[i] = points[i*2+1]

    def _dealloc_(self):
        if self._c_region_polygon is not NULL:
            if self._c_region_polygon.x is not NULL:
                                        ^
------------------------------------------------------------

toolkit/utils/region.pyx:127:40: Invalid types for 'is_not' (Python object, void *)

Error compiling Cython file:
------------------------------------------------------------
...
            self._c_region_polygon.y[i] = points[i*2+1]

    def _dealloc_(self):
        if self._c_region_polygon is not NULL:
            if self._c_region_polygon.x is not NULL:
                free(self._c_region_polygon.x)
                                           ^
------------------------------------------------------------

toolkit/utils/region.pyx:128:43: Cannot convert Python object to 'void *'

Error compiling Cython file:
------------------------------------------------------------
...

    def _dealloc_(self):
        if self._c_region_polygon is not NULL:
            if self._c_region_polygon.x is not NULL:
                free(self._c_region_polygon.x)
                self._c_region_polygon.x = NULL
                                           ^
------------------------------------------------------------

toolkit/utils/region.pyx:129:43: Cannot convert 'void *' to Python object

Error compiling Cython file:
------------------------------------------------------------
...
    def _dealloc_(self):
        if self._c_region_polygon is not NULL:
            if self._c_region_polygon.x is not NULL:
                free(self._c_region_polygon.x)
                self._c_region_polygon.x = NULL
            if self._c_region_polygon.y is not NULL:
                                        ^
------------------------------------------------------------

toolkit/utils/region.pyx:130:40: Invalid types for 'is_not' (Python object, void *)

Error compiling Cython file:
------------------------------------------------------------
...
        if self._c_region_polygon is not NULL:
            if self._c_region_polygon.x is not NULL:
                free(self._c_region_polygon.x)
                self._c_region_polygon.x = NULL
            if self._c_region_polygon.y is not NULL:
                free(self._c_region_polygon.y)
                                           ^
------------------------------------------------------------

toolkit/utils/region.pyx:131:43: Cannot convert Python object to 'void *'

Error compiling Cython file:
------------------------------------------------------------
...
            if self._c_region_polygon.x is not NULL:
                free(self._c_region_polygon.x)
                self._c_region_polygon.x = NULL
            if self._c_region_polygon.y is not NULL:
                free(self._c_region_polygon.y)
                self._c_region_polygon.y = NULL
                                           ^
------------------------------------------------------------

toolkit/utils/region.pyx:132:43: Cannot convert 'void *' to Python object

Error compiling Cython file:
------------------------------------------------------------
...
    cdef float only1 = 0
    cdef float only2 = 0
    cdef c_region.region_polygon* c_polygon1 = polygon1_._c_region_polygon
    cdef c_region.region_polygon* c_polygon2 = polygon2_._c_region_polygon
    cdef c_region.region_bounds no_bounds = pno_bounds._c_region_bounds[0] # deference
    return c_region.compute_polygon_overlap(c_polygon1,
                   ^
------------------------------------------------------------

toolkit/utils/region.pyx:185:19: cimported module has no attribute 'compute_polygon_overlap'
Traceback (most recent call last):
  File "setup.py", line 21, in <module>
    ext_modules=cythonize(ext_modules)
  File "/home/vboxuser/miniconda3/envs/pysot/lib/python3.7/site-packages/Cython/Build/Dependencies.py", line 1154, in cythonize
    cythonize_one(*args)
  File "/home/vboxuser/miniconda3/envs/pysot/lib/python3.7/site-packages/Cython/Build/Dependencies.py", line 1321, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: toolkit/utils/region.pyx
Archie945 commented 1 year ago

omg,same.do u have the solution?thanks!

L1n0A0 commented 1 year ago

Me too. Can anyone suggest a solution?thanks!!

ZXW2001 commented 1 year ago

Same, Do you guys solved it? Thanks!

Archie945 commented 1 year ago

i solved it,change python to 3.6 and install cython0.28

ZXW2001 commented 1 year ago

@Archie945 Thank you so much!

al1can commented 1 year ago

@Archie945 Thanks for the solution.