diff --git a/__pycache__/sort.cpython-38.pyc b/__pycache__/sort.cpython-38.pyc new file mode 100644 index 0000000..d5744c7 Binary files /dev/null and b/__pycache__/sort.cpython-38.pyc differ diff --git a/bins.txt b/bins.txt new file mode 100644 index 0000000..a28ecf4 Binary files /dev/null and b/bins.txt differ diff --git a/bins_default.txt b/bins_default.txt new file mode 100644 index 0000000..6299f3e Binary files /dev/null and b/bins_default.txt differ diff --git a/build/temp.linux-x86_64-3.8/detect.o b/build/temp.linux-x86_64-3.8/detect.o index 59f422d..c199bc4 100644 Binary files a/build/temp.linux-x86_64-3.8/detect.o and b/build/temp.linux-x86_64-3.8/detect.o differ diff --git a/detect.c b/detect.c index bc4984e..31941a1 100644 --- a/detect.c +++ b/detect.c @@ -1100,6 +1100,23 @@ static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, long int (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2)) #endif +/* ListAppend.proto */ +#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS +static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { + PyListObject* L = (PyListObject*) list; + Py_ssize_t len = Py_SIZE(list); + if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { + Py_INCREF(x); + PyList_SET_ITEM(list, len, x); + Py_SIZE(list) = len+1; + return 0; + } + return PyList_Append(list, x); +} +#else +#define __Pyx_PyList_Append(L,x) PyList_Append(L,x) +#endif + /* Import.proto */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); @@ -1228,16 +1245,6 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); -/* Print.proto */ -static int __Pyx_Print(PyObject*, PyObject *, int); -#if CYTHON_COMPILING_IN_PYPY || PY_MAJOR_VERSION >= 3 -static PyObject* __pyx_print = 0; -static PyObject* __pyx_print_kwargs = 0; -#endif - -/* PrintOne.proto */ -static int __Pyx_PrintOne(PyObject* stream, PyObject *o); - /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); @@ -1294,7 +1301,6 @@ static const char __pyx_k_yy[] = "yy"; static const char __pyx_k_box[] = "box"; static const char __pyx_k_cos[] = "cos"; static const char __pyx_k_cv2[] = "cv2"; -static const char __pyx_k_end[] = "end"; static const char __pyx_k_hsv[] = "hsv"; static const char __pyx_k_int[] = "int"; static const char __pyx_k_num[] = "num"; @@ -1309,10 +1315,10 @@ static const char __pyx_k_cols[] = "cols"; static const char __pyx_k_copy[] = "copy"; static const char __pyx_k_dimA[] = "dimA"; static const char __pyx_k_dimB[] = "dimB"; -static const char __pyx_k_file[] = "file"; static const char __pyx_k_gray[] = "gray"; static const char __pyx_k_hull[] = "hull"; static const char __pyx_k_line[] = "line"; +static const char __pyx_k_list[] = "list"; static const char __pyx_k_main[] = "__main__"; static const char __pyx_k_mask[] = "mask"; static const char __pyx_k_math[] = "math"; @@ -1348,7 +1354,6 @@ static const char __pyx_k_iteml[] = "iteml"; static const char __pyx_k_itemw[] = "itemw"; static const char __pyx_k_lefty[] = "lefty"; static const char __pyx_k_numpy[] = "numpy"; -static const char __pyx_k_print[] = "print"; static const char __pyx_k_quick[] = "quick"; static const char __pyx_k_round[] = "round"; static const char __pyx_k_shape[] = "shape"; @@ -1407,7 +1412,6 @@ static const char __pyx_k_cvtColor[] = "cvtColor"; static const char __pyx_k_img_file[] = "img_file"; static const char __pyx_k_mean_val[] = "mean_val"; static const char __pyx_k_midpoint[] = "midpoint"; -static const char __pyx_k_selected[] = "selected"; static const char __pyx_k_BoxPoints[] = "BoxPoints"; static const char __pyx_k_boxPoints[] = "boxPoints"; static const char __pyx_k_detect_py[] = "detect.py"; @@ -1514,10 +1518,8 @@ static PyObject *__pyx_n_s_dimB; static PyObject *__pyx_n_s_drawContours; static PyObject *__pyx_n_s_dtype; static PyObject *__pyx_n_s_edged; -static PyObject *__pyx_n_s_end; static PyObject *__pyx_n_s_epsilon; static PyObject *__pyx_n_s_erode; -static PyObject *__pyx_n_s_file; static PyObject *__pyx_n_s_findContours; static PyObject *__pyx_n_s_fitLine; static PyObject *__pyx_n_s_format; @@ -1546,6 +1548,7 @@ static PyObject *__pyx_n_s_larger; static PyObject *__pyx_n_s_lefty; static PyObject *__pyx_n_s_linalg; static PyObject *__pyx_n_s_line; +static PyObject *__pyx_n_s_list; static PyObject *__pyx_n_s_main; static PyObject *__pyx_n_s_mask; static PyObject *__pyx_n_s_math; @@ -1567,7 +1570,6 @@ static PyObject *__pyx_n_s_orig; static PyObject *__pyx_n_s_output; static PyObject *__pyx_n_s_pi; static PyObject *__pyx_n_s_pixelsPerMetric; -static PyObject *__pyx_n_s_print; static PyObject *__pyx_n_s_ptA; static PyObject *__pyx_n_s_ptB; static PyObject *__pyx_n_s_putText; @@ -1579,7 +1581,6 @@ static PyObject *__pyx_n_s_returnPoints; static PyObject *__pyx_n_s_righty; static PyObject *__pyx_n_s_round; static PyObject *__pyx_n_s_rows; -static PyObject *__pyx_n_s_selected; static PyObject *__pyx_n_s_shape; static PyObject *__pyx_n_s_shead; static PyObject *__pyx_n_s_show; @@ -2621,7 +2622,7 @@ static PyObject *__pyx_pf_6detect_12swap(CYTHON_UNUSED PyObject *__pyx_self, PyO * args = vars(ap.parse_args()) * args2 = ap.parse_args()""" * def detect(calibration_width, img_file, show, quick): # <<<<<<<<<<<<<< - * selected = 2 + * list = [] * #if type(args["number"]) == type(selected): */ @@ -2710,7 +2711,7 @@ static PyObject *__pyx_pw_6detect_15detect(PyObject *__pyx_self, PyObject *__pyx } static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_calibration_width, PyObject *__pyx_v_img_file, PyObject *__pyx_v_show, PyObject *__pyx_v_quick) { - CYTHON_UNUSED long __pyx_v_selected; + PyObject *__pyx_v_list = NULL; PyObject *__pyx_v_image = NULL; PyObject *__pyx_v_gray = NULL; PyObject *__pyx_v_edged = NULL; @@ -2794,42 +2795,34 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P PyObject *(*__pyx_t_13)(PyObject *); PyObject *(*__pyx_t_14)(PyObject *); PyObject *__pyx_t_15 = NULL; + int __pyx_t_16; __Pyx_RefNannySetupContext("detect", 0); /* "detect.py":79 * args2 = ap.parse_args()""" * def detect(calibration_width, img_file, show, quick): - * selected = 2 # <<<<<<<<<<<<<< + * list = [] # <<<<<<<<<<<<<< * #if type(args["number"]) == type(selected): * # selected = args["number"] */ - __pyx_v_selected = 2; + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_list = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; /* "detect.py":84 * * # load the image, convert it to grayscale, and blur it slightly * image = None # <<<<<<<<<<<<<< - * print(str(type(img_file))) + * #print(str(type(img_file))) * if str(type(img_file)) == "": */ __Pyx_INCREF(Py_None); __pyx_v_image = Py_None; - /* "detect.py":85 - * # load the image, convert it to grayscale, and blur it slightly - * image = None - * print(str(type(img_file))) # <<<<<<<<<<<<<< - * if str(type(img_file)) == "": - * image = img_file.copy() - */ - __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), ((PyObject *)Py_TYPE(__pyx_v_img_file))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (__Pyx_PrintOne(0, __pyx_t_1) < 0) __PYX_ERR(0, 85, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "detect.py":86 * image = None - * print(str(type(img_file))) + * #print(str(type(img_file))) * if str(type(img_file)) == "": # <<<<<<<<<<<<<< * image = img_file.copy() * else: @@ -2841,7 +2834,7 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P if (__pyx_t_2) { /* "detect.py":87 - * print(str(type(img_file))) + * #print(str(type(img_file))) * if str(type(img_file)) == "": * image = img_file.copy() # <<<<<<<<<<<<<< * else: @@ -2869,7 +2862,7 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P /* "detect.py":86 * image = None - * print(str(type(img_file))) + * #print(str(type(img_file))) * if str(type(img_file)) == "": # <<<<<<<<<<<<<< * image = img_file.copy() * else: @@ -2914,7 +2907,7 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P * #image = img_file.copy() * #image = cv2.resize(image, (int(image.shape[1]*1), int(image.shape[0]*1))) * image = cv2.resize(image, (1000, int( # <<<<<<<<<<<<<< - * image.shape[0]/image.shape[1] * 1000)), interpolation=cv2.INTER_NEAREST) + * image.shape[0]/image.shape[1] * 1000)), interpolation=cv2.INTER_NEAREST) * */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_cv2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error) @@ -2926,7 +2919,7 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P /* "detect.py":94 * #image = cv2.resize(image, (int(image.shape[1]*1), int(image.shape[0]*1))) * image = cv2.resize(image, (1000, int( - * image.shape[0]/image.shape[1] * 1000)), interpolation=cv2.INTER_NEAREST) # <<<<<<<<<<<<<< + * image.shape[0]/image.shape[1] * 1000)), interpolation=cv2.INTER_NEAREST) # <<<<<<<<<<<<<< * * if show and not quick: */ @@ -2952,7 +2945,7 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P * #image = img_file.copy() * #image = cv2.resize(image, (int(image.shape[1]*1), int(image.shape[0]*1))) * image = cv2.resize(image, (1000, int( # <<<<<<<<<<<<<< - * image.shape[0]/image.shape[1] * 1000)), interpolation=cv2.INTER_NEAREST) + * image.shape[0]/image.shape[1] * 1000)), interpolation=cv2.INTER_NEAREST) * */ __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error) @@ -2978,7 +2971,7 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P /* "detect.py":94 * #image = cv2.resize(image, (int(image.shape[1]*1), int(image.shape[0]*1))) * image = cv2.resize(image, (1000, int( - * image.shape[0]/image.shape[1] * 1000)), interpolation=cv2.INTER_NEAREST) # <<<<<<<<<<<<<< + * image.shape[0]/image.shape[1] * 1000)), interpolation=cv2.INTER_NEAREST) # <<<<<<<<<<<<<< * * if show and not quick: */ @@ -2996,7 +2989,7 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P * #image = img_file.copy() * #image = cv2.resize(image, (int(image.shape[1]*1), int(image.shape[0]*1))) * image = cv2.resize(image, (1000, int( # <<<<<<<<<<<<<< - * image.shape[0]/image.shape[1] * 1000)), interpolation=cv2.INTER_NEAREST) + * image.shape[0]/image.shape[1] * 1000)), interpolation=cv2.INTER_NEAREST) * */ __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 93, __pyx_L1_error) @@ -3008,7 +3001,7 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P __pyx_t_6 = 0; /* "detect.py":96 - * image.shape[0]/image.shape[1] * 1000)), interpolation=cv2.INTER_NEAREST) + * image.shape[0]/image.shape[1] * 1000)), interpolation=cv2.INTER_NEAREST) * * if show and not quick: # <<<<<<<<<<<<<< * cv2.namedWindow("Item Sorter") @@ -3144,7 +3137,7 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; /* "detect.py":96 - * image.shape[0]/image.shape[1] * 1000)), interpolation=cv2.INTER_NEAREST) + * image.shape[0]/image.shape[1] * 1000)), interpolation=cv2.INTER_NEAREST) * * if show and not quick: # <<<<<<<<<<<<<< * cv2.namedWindow("Item Sorter") @@ -6822,522 +6815,318 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P * dimA = dA / pixelsPerMetric * dimB = dB / pixelsPerMetric # <<<<<<<<<<<<<< * - * if num == num or show: + * # Item detection */ __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_v_dB, __pyx_v_pixelsPerMetric); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 233, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_dimB, __pyx_t_3); __pyx_t_3 = 0; - /* "detect.py":235 - * dimB = dB / pixelsPerMetric - * - * if num == num or show: # <<<<<<<<<<<<<< - * area_box = dA * dB - * (x, y), radius = cv2.minEnclosingCircle(c) - */ - __pyx_t_3 = PyObject_RichCompare(__pyx_v_num, __pyx_v_num, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 235, __pyx_L1_error) - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 235, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (!__pyx_t_7) { - } else { - __pyx_t_2 = __pyx_t_7; - goto __pyx_L54_bool_binop_done; - } - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_show); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 235, __pyx_L1_error) - __pyx_t_2 = __pyx_t_7; - __pyx_L54_bool_binop_done:; - if (__pyx_t_2) { - - /* "detect.py":236 + /* "detect.py":236 * - * if num == num or show: - * area_box = dA * dB # <<<<<<<<<<<<<< - * (x, y), radius = cv2.minEnclosingCircle(c) - * area_contour = cv2.contourArea(c) + * # Item detection + * area_box = dA * dB # <<<<<<<<<<<<<< + * (x, y), radius = cv2.minEnclosingCircle(c) + * area_contour = cv2.contourArea(c) */ - __pyx_t_3 = PyNumber_Multiply(__pyx_v_dA, __pyx_v_dB); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 236, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_XDECREF_SET(__pyx_v_area_box, __pyx_t_3); - __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_Multiply(__pyx_v_dA, __pyx_v_dB); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 236, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_XDECREF_SET(__pyx_v_area_box, __pyx_t_3); + __pyx_t_3 = 0; - /* "detect.py":237 - * if num == num or show: - * area_box = dA * dB - * (x, y), radius = cv2.minEnclosingCircle(c) # <<<<<<<<<<<<<< - * area_contour = cv2.contourArea(c) - * area_circle = math.pi * pow(radius, 2) + /* "detect.py":237 + * # Item detection + * area_box = dA * dB + * (x, y), radius = cv2.minEnclosingCircle(c) # <<<<<<<<<<<<<< + * area_contour = cv2.contourArea(c) + * area_circle = math.pi * pow(radius, 2) */ - __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_cv2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 237, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_minEnclosingCircle); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 237, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_11)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_11); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - __pyx_t_3 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_11, __pyx_v_c) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_c); - __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 237, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { - PyObject* sequence = __pyx_t_3; - Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); - if (unlikely(size != 2)) { - if (size > 2) __Pyx_RaiseTooManyValuesError(2); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 237, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); - } else { - __pyx_t_1 = PyList_GET_ITEM(sequence, 0); - __pyx_t_11 = PyList_GET_ITEM(sequence, 1); - } - __Pyx_INCREF(__pyx_t_1); + __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_cv2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 237, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_minEnclosingCircle); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 237, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_11)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_11); - #else - __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 237, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 237, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - #endif - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else { - Py_ssize_t index = -1; - __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 237, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_14 = Py_TYPE(__pyx_t_4)->tp_iternext; - index = 0; __pyx_t_1 = __pyx_t_14(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L56_unpacking_failed; - __Pyx_GOTREF(__pyx_t_1); - index = 1; __pyx_t_11 = __pyx_t_14(__pyx_t_4); if (unlikely(!__pyx_t_11)) goto __pyx_L56_unpacking_failed; - __Pyx_GOTREF(__pyx_t_11); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_4), 2) < 0) __PYX_ERR(0, 237, __pyx_L1_error) - __pyx_t_14 = NULL; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - goto __pyx_L57_unpacking_done; - __pyx_L56_unpacking_failed:; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_14 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + } + } + __pyx_t_3 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_11, __pyx_v_c) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_c); + __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 237, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { + PyObject* sequence = __pyx_t_3; + Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 237, __pyx_L1_error) - __pyx_L57_unpacking_done:; } - if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { - PyObject* sequence = __pyx_t_1; - Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); - if (unlikely(size != 2)) { - if (size > 2) __Pyx_RaiseTooManyValuesError(2); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 237, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); - } else { - __pyx_t_4 = PyList_GET_ITEM(sequence, 0); - __pyx_t_6 = PyList_GET_ITEM(sequence, 1); - } - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(__pyx_t_6); - #else - __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 237, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 237, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - #endif - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); } else { - Py_ssize_t index = -1; - __pyx_t_10 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 237, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_14 = Py_TYPE(__pyx_t_10)->tp_iternext; - index = 0; __pyx_t_4 = __pyx_t_14(__pyx_t_10); if (unlikely(!__pyx_t_4)) goto __pyx_L58_unpacking_failed; - __Pyx_GOTREF(__pyx_t_4); - index = 1; __pyx_t_6 = __pyx_t_14(__pyx_t_10); if (unlikely(!__pyx_t_6)) goto __pyx_L58_unpacking_failed; - __Pyx_GOTREF(__pyx_t_6); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_10), 2) < 0) __PYX_ERR(0, 237, __pyx_L1_error) - __pyx_t_14 = NULL; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - goto __pyx_L59_unpacking_done; - __pyx_L58_unpacking_failed:; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_14 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 237, __pyx_L1_error) - __pyx_L59_unpacking_done:; + __pyx_t_1 = PyList_GET_ITEM(sequence, 0); + __pyx_t_11 = PyList_GET_ITEM(sequence, 1); } - __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_4); - __pyx_t_4 = 0; - __Pyx_XDECREF_SET(__pyx_v_y, __pyx_t_6); - __pyx_t_6 = 0; - __Pyx_XDECREF_SET(__pyx_v_radius, __pyx_t_11); - __pyx_t_11 = 0; - - /* "detect.py":238 - * area_box = dA * dB - * (x, y), radius = cv2.minEnclosingCircle(c) - * area_contour = cv2.contourArea(c) # <<<<<<<<<<<<<< - * area_circle = math.pi * pow(radius, 2) - * boxiness = area_contour / area_box - */ - __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_cv2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 238, __pyx_L1_error) + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(__pyx_t_11); + #else + __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 237, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 237, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_contourArea); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 238, __pyx_L1_error) + #endif + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else { + Py_ssize_t index = -1; + __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 237, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_14 = Py_TYPE(__pyx_t_4)->tp_iternext; + index = 0; __pyx_t_1 = __pyx_t_14(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L53_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_11)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_11); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } + index = 1; __pyx_t_11 = __pyx_t_14(__pyx_t_4); if (unlikely(!__pyx_t_11)) goto __pyx_L53_unpacking_failed; + __Pyx_GOTREF(__pyx_t_11); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_4), 2) < 0) __PYX_ERR(0, 237, __pyx_L1_error) + __pyx_t_14 = NULL; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + goto __pyx_L54_unpacking_done; + __pyx_L53_unpacking_failed:; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_14 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + __PYX_ERR(0, 237, __pyx_L1_error) + __pyx_L54_unpacking_done:; + } + if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { + PyObject* sequence = __pyx_t_1; + Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(0, 237, __pyx_L1_error) } - __pyx_t_3 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_11, __pyx_v_c) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_c); - __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 238, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); + } else { + __pyx_t_4 = PyList_GET_ITEM(sequence, 0); + __pyx_t_6 = PyList_GET_ITEM(sequence, 1); + } + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(__pyx_t_6); + #else + __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 237, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 237, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF_SET(__pyx_v_area_contour, __pyx_t_3); - __pyx_t_3 = 0; - - /* "detect.py":239 - * (x, y), radius = cv2.minEnclosingCircle(c) - * area_contour = cv2.contourArea(c) - * area_circle = math.pi * pow(radius, 2) # <<<<<<<<<<<<<< - * boxiness = area_contour / area_box - * circleness = area_contour / area_circle - */ - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_math); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 239, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_pi); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyNumber_Power2(__pyx_v_radius, __pyx_int_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 239, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_11 = PyNumber_Multiply(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 239, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); + } else { + Py_ssize_t index = -1; + __pyx_t_10 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 237, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_XDECREF_SET(__pyx_v_area_circle, __pyx_t_11); - __pyx_t_11 = 0; + __pyx_t_14 = Py_TYPE(__pyx_t_10)->tp_iternext; + index = 0; __pyx_t_4 = __pyx_t_14(__pyx_t_10); if (unlikely(!__pyx_t_4)) goto __pyx_L55_unpacking_failed; + __Pyx_GOTREF(__pyx_t_4); + index = 1; __pyx_t_6 = __pyx_t_14(__pyx_t_10); if (unlikely(!__pyx_t_6)) goto __pyx_L55_unpacking_failed; + __Pyx_GOTREF(__pyx_t_6); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_10), 2) < 0) __PYX_ERR(0, 237, __pyx_L1_error) + __pyx_t_14 = NULL; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + goto __pyx_L56_unpacking_done; + __pyx_L55_unpacking_failed:; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_14 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + __PYX_ERR(0, 237, __pyx_L1_error) + __pyx_L56_unpacking_done:; + } + __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_4); + __pyx_t_4 = 0; + __Pyx_XDECREF_SET(__pyx_v_y, __pyx_t_6); + __pyx_t_6 = 0; + __Pyx_XDECREF_SET(__pyx_v_radius, __pyx_t_11); + __pyx_t_11 = 0; - /* "detect.py":240 - * area_contour = cv2.contourArea(c) - * area_circle = math.pi * pow(radius, 2) - * boxiness = area_contour / area_box # <<<<<<<<<<<<<< - * circleness = area_contour / area_circle - * circular = False + /* "detect.py":238 + * area_box = dA * dB + * (x, y), radius = cv2.minEnclosingCircle(c) + * area_contour = cv2.contourArea(c) # <<<<<<<<<<<<<< + * area_circle = math.pi * pow(radius, 2) + * boxiness = area_contour / area_box */ - __pyx_t_11 = __Pyx_PyNumber_Divide(__pyx_v_area_contour, __pyx_v_area_box); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 240, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_XDECREF_SET(__pyx_v_boxiness, __pyx_t_11); - __pyx_t_11 = 0; + __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_cv2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 238, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_contourArea); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 238, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_11)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_11); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + } + } + __pyx_t_3 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_11, __pyx_v_c) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_c); + __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 238, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF_SET(__pyx_v_area_contour, __pyx_t_3); + __pyx_t_3 = 0; - /* "detect.py":241 - * area_circle = math.pi * pow(radius, 2) - * boxiness = area_contour / area_box - * circleness = area_contour / area_circle # <<<<<<<<<<<<<< - * circular = False - * rectangular = False + /* "detect.py":239 + * (x, y), radius = cv2.minEnclosingCircle(c) + * area_contour = cv2.contourArea(c) + * area_circle = math.pi * pow(radius, 2) # <<<<<<<<<<<<<< + * boxiness = area_contour / area_box + * circleness = area_contour / area_circle */ - __pyx_t_11 = __Pyx_PyNumber_Divide(__pyx_v_area_contour, __pyx_v_area_circle); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 241, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_XDECREF_SET(__pyx_v_circleness, __pyx_t_11); - __pyx_t_11 = 0; + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_math); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 239, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_pi); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyNumber_Power2(__pyx_v_radius, __pyx_int_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 239, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_11 = PyNumber_Multiply(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 239, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF_SET(__pyx_v_area_circle, __pyx_t_11); + __pyx_t_11 = 0; - /* "detect.py":242 - * boxiness = area_contour / area_box - * circleness = area_contour / area_circle - * circular = False # <<<<<<<<<<<<<< - * rectangular = False - * if boxiness > circleness: + /* "detect.py":240 + * area_contour = cv2.contourArea(c) + * area_circle = math.pi * pow(radius, 2) + * boxiness = area_contour / area_box # <<<<<<<<<<<<<< + * circleness = area_contour / area_circle + * circular = False */ - __pyx_v_circular = 0; + __pyx_t_11 = __Pyx_PyNumber_Divide(__pyx_v_area_contour, __pyx_v_area_box); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 240, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_XDECREF_SET(__pyx_v_boxiness, __pyx_t_11); + __pyx_t_11 = 0; - /* "detect.py":243 - * circleness = area_contour / area_circle - * circular = False - * rectangular = False # <<<<<<<<<<<<<< - * if boxiness > circleness: - * rectangular = True + /* "detect.py":241 + * area_circle = math.pi * pow(radius, 2) + * boxiness = area_contour / area_box + * circleness = area_contour / area_circle # <<<<<<<<<<<<<< + * circular = False + * rectangular = False */ - __pyx_v_rectangular = 0; + __pyx_t_11 = __Pyx_PyNumber_Divide(__pyx_v_area_contour, __pyx_v_area_circle); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 241, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_XDECREF_SET(__pyx_v_circleness, __pyx_t_11); + __pyx_t_11 = 0; - /* "detect.py":244 - * circular = False - * rectangular = False - * if boxiness > circleness: # <<<<<<<<<<<<<< - * rectangular = True - * #cv2.drawContours(orig, [box.astype("int")], -1, (0, 255, 0), 2) - */ - __pyx_t_11 = PyObject_RichCompare(__pyx_v_boxiness, __pyx_v_circleness, Py_GT); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 244, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 244, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - if (__pyx_t_2) { - - /* "detect.py":245 - * rectangular = False - * if boxiness > circleness: - * rectangular = True # <<<<<<<<<<<<<< - * #cv2.drawContours(orig, [box.astype("int")], -1, (0, 255, 0), 2) - * else: - */ - __pyx_v_rectangular = 1; - - /* "detect.py":244 - * circular = False - * rectangular = False - * if boxiness > circleness: # <<<<<<<<<<<<<< - * rectangular = True - * #cv2.drawContours(orig, [box.astype("int")], -1, (0, 255, 0), 2) - */ - goto __pyx_L60; - } - - /* "detect.py":248 - * #cv2.drawContours(orig, [box.astype("int")], -1, (0, 255, 0), 2) - * else: - * circular = True # <<<<<<<<<<<<<< - * cv2.circle(orig, (int(x), int(y)), int(radius), (255, 0, 0), 2) - * - */ - /*else*/ { - __pyx_v_circular = 1; - - /* "detect.py":249 - * else: - * circular = True - * cv2.circle(orig, (int(x), int(y)), int(radius), (255, 0, 0), 2) # <<<<<<<<<<<<<< - * - * objtype = "Unknown" - */ - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_cv2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_circle); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_x); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = __Pyx_PyNumber_Int(__pyx_v_y); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_6); - __pyx_t_3 = 0; - __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyNumber_Int(__pyx_v_radius); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_3 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_v_orig, __pyx_t_4, __pyx_t_6, __pyx_tuple__4, __pyx_int_2}; - __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_v_orig, __pyx_t_4, __pyx_t_6, __pyx_tuple__4, __pyx_int_2}; - __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - { - __pyx_t_10 = PyTuple_New(5+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - if (__pyx_t_3) { - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3); __pyx_t_3 = NULL; - } - __Pyx_INCREF(__pyx_v_orig); - __Pyx_GIVEREF(__pyx_v_orig); - PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_v_orig); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_6); - __Pyx_INCREF(__pyx_tuple__4); - __Pyx_GIVEREF(__pyx_tuple__4); - PyTuple_SET_ITEM(__pyx_t_10, 3+__pyx_t_9, __pyx_tuple__4); - __Pyx_INCREF(__pyx_int_2); - __Pyx_GIVEREF(__pyx_int_2); - PyTuple_SET_ITEM(__pyx_t_10, 4+__pyx_t_9, __pyx_int_2); - __pyx_t_4 = 0; - __pyx_t_6 = 0; - __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - } - __pyx_L60:; - - /* "detect.py":251 - * cv2.circle(orig, (int(x), int(y)), int(radius), (255, 0, 0), 2) - * - * objtype = "Unknown" # <<<<<<<<<<<<<< - * itemw = larger(dimA, dimB) - * itemwr = itemw + /* "detect.py":242 + * boxiness = area_contour / area_box + * circleness = area_contour / area_circle + * circular = False # <<<<<<<<<<<<<< + * rectangular = False + * if boxiness > circleness: */ - __Pyx_INCREF(__pyx_n_s_Unknown); - __Pyx_DECREF_SET(__pyx_v_objtype, __pyx_n_s_Unknown); + __pyx_v_circular = 0; - /* "detect.py":252 - * - * objtype = "Unknown" - * itemw = larger(dimA, dimB) # <<<<<<<<<<<<<< - * itemwr = itemw - * itemwr *= 8 + /* "detect.py":243 + * circleness = area_contour / area_circle + * circular = False + * rectangular = False # <<<<<<<<<<<<<< + * if boxiness > circleness: + * rectangular = True */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_larger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 252, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_10)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_10); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_dimA, __pyx_v_dimB}; - __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 252, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_GOTREF(__pyx_t_11); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_dimA, __pyx_v_dimB}; - __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 252, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_GOTREF(__pyx_t_11); - } else - #endif - { - __pyx_t_6 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 252, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - if (__pyx_t_10) { - __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_10); __pyx_t_10 = NULL; - } - __Pyx_INCREF(__pyx_v_dimA); - __Pyx_GIVEREF(__pyx_v_dimA); - PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_9, __pyx_v_dimA); - __Pyx_INCREF(__pyx_v_dimB); - __Pyx_GIVEREF(__pyx_v_dimB); - PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_9, __pyx_v_dimB); - __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 252, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF_SET(__pyx_v_itemw, __pyx_t_11); - __pyx_t_11 = 0; + __pyx_v_rectangular = 0; - /* "detect.py":253 - * objtype = "Unknown" - * itemw = larger(dimA, dimB) - * itemwr = itemw # <<<<<<<<<<<<<< - * itemwr *= 8 - * itemwr = round(itemwr) + /* "detect.py":244 + * circular = False + * rectangular = False + * if boxiness > circleness: # <<<<<<<<<<<<<< + * rectangular = True + * #cv2.drawContours(orig, [box.astype("int")], -1, (0, 255, 0), 2) */ - __Pyx_INCREF(__pyx_v_itemw); - __Pyx_XDECREF_SET(__pyx_v_itemwr, __pyx_v_itemw); + __pyx_t_11 = PyObject_RichCompare(__pyx_v_boxiness, __pyx_v_circleness, Py_GT); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 244, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 244, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + if (__pyx_t_2) { - /* "detect.py":254 - * itemw = larger(dimA, dimB) - * itemwr = itemw - * itemwr *= 8 # <<<<<<<<<<<<<< - * itemwr = round(itemwr) - * itemwr /= 8 + /* "detect.py":245 + * rectangular = False + * if boxiness > circleness: + * rectangular = True # <<<<<<<<<<<<<< + * #cv2.drawContours(orig, [box.astype("int")], -1, (0, 255, 0), 2) + * else: */ - __pyx_t_11 = PyNumber_InPlaceMultiply(__pyx_v_itemwr, __pyx_int_8); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 254, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF_SET(__pyx_v_itemwr, __pyx_t_11); - __pyx_t_11 = 0; + __pyx_v_rectangular = 1; - /* "detect.py":255 - * itemwr = itemw - * itemwr *= 8 - * itemwr = round(itemwr) # <<<<<<<<<<<<<< - * itemwr /= 8 - * + /* "detect.py":244 + * circular = False + * rectangular = False + * if boxiness > circleness: # <<<<<<<<<<<<<< + * rectangular = True + * #cv2.drawContours(orig, [box.astype("int")], -1, (0, 255, 0), 2) */ - __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_round, __pyx_v_itemwr); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 255, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF_SET(__pyx_v_itemwr, __pyx_t_11); - __pyx_t_11 = 0; + goto __pyx_L57; + } - /* "detect.py":256 - * itemwr *= 8 - * itemwr = round(itemwr) - * itemwr /= 8 # <<<<<<<<<<<<<< - * - * itemh = smaller(dimA, dimB) + /* "detect.py":248 + * #cv2.drawContours(orig, [box.astype("int")], -1, (0, 255, 0), 2) + * else: + * circular = True # <<<<<<<<<<<<<< + * cv2.circle(orig, (int(x), int(y)), int(radius), (255, 0, 0), 2) + * objtype = "Unknown" */ - __pyx_t_11 = __Pyx_PyNumber_InPlaceDivide(__pyx_v_itemwr, __pyx_int_8); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 256, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF_SET(__pyx_v_itemwr, __pyx_t_11); - __pyx_t_11 = 0; + /*else*/ { + __pyx_v_circular = 1; - /* "detect.py":258 - * itemwr /= 8 - * - * itemh = smaller(dimA, dimB) # <<<<<<<<<<<<<< - * itemhr = itemh - * itemhr *= 16 + /* "detect.py":249 + * else: + * circular = True + * cv2.circle(orig, (int(x), int(y)), int(radius), (255, 0, 0), 2) # <<<<<<<<<<<<<< + * objtype = "Unknown" + * itemw = larger(dimA, dimB) */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_smaller); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 258, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_cv2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 249, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_circle); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = NULL; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_x); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 249, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = __Pyx_PyNumber_Int(__pyx_v_y); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 249, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 249, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_6); + __pyx_t_3 = 0; + __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyNumber_Int(__pyx_v_radius); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 249, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_3 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_6)) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_9 = 1; @@ -7345,698 +7134,659 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_dimA, __pyx_v_dimB}; - __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 258, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_v_orig, __pyx_t_4, __pyx_t_6, __pyx_tuple__4, __pyx_int_2}; + __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 249, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_dimA, __pyx_v_dimB}; - __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 258, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_v_orig, __pyx_t_4, __pyx_t_6, __pyx_tuple__4, __pyx_int_2}; + __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 249, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { - __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 258, __pyx_L1_error) + __pyx_t_10 = PyTuple_New(5+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - if (__pyx_t_6) { - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_6); __pyx_t_6 = NULL; - } - __Pyx_INCREF(__pyx_v_dimA); - __Pyx_GIVEREF(__pyx_v_dimA); - PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_v_dimA); - __Pyx_INCREF(__pyx_v_dimB); - __Pyx_GIVEREF(__pyx_v_dimB); - PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_v_dimB); - __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 258, __pyx_L1_error) + if (__pyx_t_3) { + __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3); __pyx_t_3 = NULL; + } + __Pyx_INCREF(__pyx_v_orig); + __Pyx_GIVEREF(__pyx_v_orig); + PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_v_orig); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_6); + __Pyx_INCREF(__pyx_tuple__4); + __Pyx_GIVEREF(__pyx_tuple__4); + PyTuple_SET_ITEM(__pyx_t_10, 3+__pyx_t_9, __pyx_tuple__4); + __Pyx_INCREF(__pyx_int_2); + __Pyx_GIVEREF(__pyx_int_2); + PyTuple_SET_ITEM(__pyx_t_10, 4+__pyx_t_9, __pyx_int_2); + __pyx_t_4 = 0; + __pyx_t_6 = 0; + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF_SET(__pyx_v_itemh, __pyx_t_11); - __pyx_t_11 = 0; - - /* "detect.py":259 - * - * itemh = smaller(dimA, dimB) - * itemhr = itemh # <<<<<<<<<<<<<< - * itemhr *= 16 - * itemhr = round(itemhr) - */ - __Pyx_INCREF(__pyx_v_itemh); - __Pyx_XDECREF_SET(__pyx_v_itemhr, __pyx_v_itemh); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } + __pyx_L57:; - /* "detect.py":260 - * itemh = smaller(dimA, dimB) - * itemhr = itemh - * itemhr *= 16 # <<<<<<<<<<<<<< - * itemhr = round(itemhr) - * itemhr /= 16 - */ - __pyx_t_11 = PyNumber_InPlaceMultiply(__pyx_v_itemhr, __pyx_int_16); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 260, __pyx_L1_error) + /* "detect.py":250 + * circular = True + * cv2.circle(orig, (int(x), int(y)), int(radius), (255, 0, 0), 2) + * objtype = "Unknown" # <<<<<<<<<<<<<< + * itemw = larger(dimA, dimB) + * itemwr = itemw + */ + __Pyx_INCREF(__pyx_n_s_Unknown); + __Pyx_DECREF_SET(__pyx_v_objtype, __pyx_n_s_Unknown); + + /* "detect.py":251 + * cv2.circle(orig, (int(x), int(y)), int(radius), (255, 0, 0), 2) + * objtype = "Unknown" + * itemw = larger(dimA, dimB) # <<<<<<<<<<<<<< + * itemwr = itemw + * itemwr *= 8 + */ + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_larger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 251, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_10 = NULL; + __pyx_t_9 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_10)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_10); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + __pyx_t_9 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_dimA, __pyx_v_dimB}; + __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 251, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF_SET(__pyx_v_itemhr, __pyx_t_11); - __pyx_t_11 = 0; - - /* "detect.py":261 - * itemhr = itemh - * itemhr *= 16 - * itemhr = round(itemhr) # <<<<<<<<<<<<<< - * itemhr /= 16 - * if circular and itemwr == 0.75: - */ - __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_round, __pyx_v_itemhr); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 261, __pyx_L1_error) + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_dimA, __pyx_v_dimB}; + __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 251, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF_SET(__pyx_v_itemhr, __pyx_t_11); - __pyx_t_11 = 0; - - /* "detect.py":262 - * itemhr *= 16 - * itemhr = round(itemhr) - * itemhr /= 16 # <<<<<<<<<<<<<< - * if circular and itemwr == 0.75: - * objtype = "Penny" - */ - __pyx_t_11 = __Pyx_PyNumber_InPlaceDivide(__pyx_v_itemhr, __pyx_int_16); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 262, __pyx_L1_error) + } else + #endif + { + __pyx_t_6 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 251, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (__pyx_t_10) { + __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_10); __pyx_t_10 = NULL; + } + __Pyx_INCREF(__pyx_v_dimA); + __Pyx_GIVEREF(__pyx_v_dimA); + PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_9, __pyx_v_dimA); + __Pyx_INCREF(__pyx_v_dimB); + __Pyx_GIVEREF(__pyx_v_dimB); + PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_9, __pyx_v_dimB); + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF_SET(__pyx_v_itemhr, __pyx_t_11); - __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF_SET(__pyx_v_itemw, __pyx_t_11); + __pyx_t_11 = 0; - /* "detect.py":263 - * itemhr = round(itemhr) - * itemhr /= 16 - * if circular and itemwr == 0.75: # <<<<<<<<<<<<<< - * objtype = "Penny" - * iteml = 0 + /* "detect.py":252 + * objtype = "Unknown" + * itemw = larger(dimA, dimB) + * itemwr = itemw # <<<<<<<<<<<<<< + * itemwr *= 8 + * itemwr = round(itemwr) */ - __pyx_t_7 = (__pyx_v_circular != 0); - if (__pyx_t_7) { - } else { - __pyx_t_2 = __pyx_t_7; - goto __pyx_L62_bool_binop_done; - } - __pyx_t_11 = __Pyx_PyFloat_EqObjC(__pyx_v_itemwr, __pyx_float_0_75, 0.75, 0, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 263, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 263, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_2 = __pyx_t_7; - __pyx_L62_bool_binop_done:; - if (__pyx_t_2) { + __Pyx_INCREF(__pyx_v_itemw); + __Pyx_XDECREF_SET(__pyx_v_itemwr, __pyx_v_itemw); - /* "detect.py":264 - * itemhr /= 16 - * if circular and itemwr == 0.75: - * objtype = "Penny" # <<<<<<<<<<<<<< - * iteml = 0 - * else: + /* "detect.py":253 + * itemw = larger(dimA, dimB) + * itemwr = itemw + * itemwr *= 8 # <<<<<<<<<<<<<< + * itemwr = round(itemwr) + * itemwr /= 8 */ - __Pyx_INCREF(__pyx_n_s_Penny); - __Pyx_DECREF_SET(__pyx_v_objtype, __pyx_n_s_Penny); + __pyx_t_11 = PyNumber_InPlaceMultiply(__pyx_v_itemwr, __pyx_int_8); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 253, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF_SET(__pyx_v_itemwr, __pyx_t_11); + __pyx_t_11 = 0; - /* "detect.py":265 - * if circular and itemwr == 0.75: - * objtype = "Penny" - * iteml = 0 # <<<<<<<<<<<<<< - * else: - * if circular and near(radius * 2 / pixelsPerMetric, 0.38, 0.03): + /* "detect.py":254 + * itemwr = itemw + * itemwr *= 8 + * itemwr = round(itemwr) # <<<<<<<<<<<<<< + * itemwr /= 8 + * itemh = smaller(dimA, dimB) */ - __Pyx_INCREF(__pyx_int_0); - __Pyx_XDECREF_SET(__pyx_v_iteml, __pyx_int_0); + __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_round, __pyx_v_itemwr); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 254, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF_SET(__pyx_v_itemwr, __pyx_t_11); + __pyx_t_11 = 0; - /* "detect.py":263 - * itemhr = round(itemhr) - * itemhr /= 16 - * if circular and itemwr == 0.75: # <<<<<<<<<<<<<< - * objtype = "Penny" - * iteml = 0 + /* "detect.py":255 + * itemwr *= 8 + * itemwr = round(itemwr) + * itemwr /= 8 # <<<<<<<<<<<<<< + * itemh = smaller(dimA, dimB) + * itemhr = itemh */ - goto __pyx_L61; - } + __pyx_t_11 = __Pyx_PyNumber_InPlaceDivide(__pyx_v_itemwr, __pyx_int_8); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 255, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF_SET(__pyx_v_itemwr, __pyx_t_11); + __pyx_t_11 = 0; - /* "detect.py":267 - * iteml = 0 - * else: - * if circular and near(radius * 2 / pixelsPerMetric, 0.38, 0.03): # <<<<<<<<<<<<<< - * # Keps nut or spacer - * objtype = "Spacer" + /* "detect.py":256 + * itemwr = round(itemwr) + * itemwr /= 8 + * itemh = smaller(dimA, dimB) # <<<<<<<<<<<<<< + * itemhr = itemh + * itemhr *= 16 */ - /*else*/ { - __pyx_t_7 = (__pyx_v_circular != 0); - if (__pyx_t_7) { - } else { - __pyx_t_2 = __pyx_t_7; - goto __pyx_L65_bool_binop_done; - } - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_near); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 267, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = PyNumber_Multiply(__pyx_v_radius, __pyx_int_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 267, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_6 = __Pyx_PyNumber_Divide(__pyx_t_10, __pyx_v_pixelsPerMetric); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 267, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_smaller); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 256, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = NULL; + __pyx_t_9 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + __pyx_t_9 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_dimA, __pyx_v_dimB}; + __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 256, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_11); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_dimA, __pyx_v_dimB}; + __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 256, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_11); + } else + #endif + { + __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 256, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + if (__pyx_t_6) { + __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_6); __pyx_t_6 = NULL; + } + __Pyx_INCREF(__pyx_v_dimA); + __Pyx_GIVEREF(__pyx_v_dimA); + PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_v_dimA); + __Pyx_INCREF(__pyx_v_dimB); + __Pyx_GIVEREF(__pyx_v_dimB); + PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_v_dimB); + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 256, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF_SET(__pyx_v_itemh, __pyx_t_11); + __pyx_t_11 = 0; + + /* "detect.py":257 + * itemwr /= 8 + * itemh = smaller(dimA, dimB) + * itemhr = itemh # <<<<<<<<<<<<<< + * itemhr *= 16 + * itemhr = round(itemhr) + */ + __Pyx_INCREF(__pyx_v_itemh); + __Pyx_XDECREF_SET(__pyx_v_itemhr, __pyx_v_itemh); + + /* "detect.py":258 + * itemh = smaller(dimA, dimB) + * itemhr = itemh + * itemhr *= 16 # <<<<<<<<<<<<<< + * itemhr = round(itemhr) + * itemhr /= 16 + */ + __pyx_t_11 = PyNumber_InPlaceMultiply(__pyx_v_itemhr, __pyx_int_16); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 258, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF_SET(__pyx_v_itemhr, __pyx_t_11); + __pyx_t_11 = 0; + + /* "detect.py":259 + * itemhr = itemh + * itemhr *= 16 + * itemhr = round(itemhr) # <<<<<<<<<<<<<< + * itemhr /= 16 + * if circular and itemwr == 0.75: + */ + __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_round, __pyx_v_itemhr); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 259, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF_SET(__pyx_v_itemhr, __pyx_t_11); + __pyx_t_11 = 0; + + /* "detect.py":260 + * itemhr *= 16 + * itemhr = round(itemhr) + * itemhr /= 16 # <<<<<<<<<<<<<< + * if circular and itemwr == 0.75: + * objtype = "Penny" + */ + __pyx_t_11 = __Pyx_PyNumber_InPlaceDivide(__pyx_v_itemhr, __pyx_int_16); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 260, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF_SET(__pyx_v_itemhr, __pyx_t_11); + __pyx_t_11 = 0; + + /* "detect.py":261 + * itemhr = round(itemhr) + * itemhr /= 16 + * if circular and itemwr == 0.75: # <<<<<<<<<<<<<< + * objtype = "Penny" + * iteml = 0 + */ + __pyx_t_7 = (__pyx_v_circular != 0); + if (__pyx_t_7) { + } else { + __pyx_t_2 = __pyx_t_7; + goto __pyx_L59_bool_binop_done; + } + __pyx_t_11 = __Pyx_PyFloat_EqObjC(__pyx_v_itemwr, __pyx_float_0_75, 0.75, 0, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 261, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 261, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_2 = __pyx_t_7; + __pyx_L59_bool_binop_done:; + if (__pyx_t_2) { + + /* "detect.py":262 + * itemhr /= 16 + * if circular and itemwr == 0.75: + * objtype = "Penny" # <<<<<<<<<<<<<< + * iteml = 0 + * else: + */ + __Pyx_INCREF(__pyx_n_s_Penny); + __Pyx_DECREF_SET(__pyx_v_objtype, __pyx_n_s_Penny); + + /* "detect.py":263 + * if circular and itemwr == 0.75: + * objtype = "Penny" + * iteml = 0 # <<<<<<<<<<<<<< + * else: + * if circular and near(radius * 2 / pixelsPerMetric, 0.38, 0.03): + */ + __Pyx_INCREF(__pyx_int_0); + __Pyx_XDECREF_SET(__pyx_v_iteml, __pyx_int_0); + + /* "detect.py":261 + * itemhr = round(itemhr) + * itemhr /= 16 + * if circular and itemwr == 0.75: # <<<<<<<<<<<<<< + * objtype = "Penny" + * iteml = 0 + */ + goto __pyx_L58; + } + + /* "detect.py":265 + * iteml = 0 + * else: + * if circular and near(radius * 2 / pixelsPerMetric, 0.38, 0.03): # <<<<<<<<<<<<<< + * # Keps nut or spacer + * objtype = "Spacer" + */ + /*else*/ { + __pyx_t_7 = (__pyx_v_circular != 0); + if (__pyx_t_7) { + } else { + __pyx_t_2 = __pyx_t_7; + goto __pyx_L62_bool_binop_done; + } + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_near); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 265, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_10 = PyNumber_Multiply(__pyx_v_radius, __pyx_int_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 265, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_6 = __Pyx_PyNumber_Divide(__pyx_t_10, __pyx_v_pixelsPerMetric); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 265, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = NULL; + __pyx_t_9 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_10)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_10); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + __pyx_t_9 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_t_6, __pyx_float_0_38, __pyx_float_0_03}; + __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 265, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_t_6, __pyx_float_0_38, __pyx_float_0_03}; + __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 265, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } else + #endif + { + __pyx_t_4 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 265, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + if (__pyx_t_10) { + __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_10); __pyx_t_10 = NULL; + } + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_9, __pyx_t_6); + __Pyx_INCREF(__pyx_float_0_38); + __Pyx_GIVEREF(__pyx_float_0_38); + PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_9, __pyx_float_0_38); + __Pyx_INCREF(__pyx_float_0_03); + __Pyx_GIVEREF(__pyx_float_0_03); + PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_9, __pyx_float_0_03); + __pyx_t_6 = 0; + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 265, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 265, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_2 = __pyx_t_7; + __pyx_L62_bool_binop_done:; + if (__pyx_t_2) { + + /* "detect.py":267 + * if circular and near(radius * 2 / pixelsPerMetric, 0.38, 0.03): + * # Keps nut or spacer + * objtype = "Spacer" # <<<<<<<<<<<<<< + * mask = np.zeros(gray.shape, np.uint8) + * cv2.drawContours(mask, [c], 0, 255, -1) + */ + __Pyx_INCREF(__pyx_n_s_Spacer); + __Pyx_DECREF_SET(__pyx_v_objtype, __pyx_n_s_Spacer); + + /* "detect.py":268 + * # Keps nut or spacer + * objtype = "Spacer" + * mask = np.zeros(gray.shape, np.uint8) # <<<<<<<<<<<<<< + * cv2.drawContours(mask, [c], 0, 255, -1) + * #pixelpoints = np.transpose(np.nonzero(mask)) + */ + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 268, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 268, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_gray, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 268, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 268, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = NULL; + __pyx_t_9 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_9 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_1, __pyx_t_10}; + __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 268, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_1, __pyx_t_10}; + __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 268, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } else + #endif + { + __pyx_t_3 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 268, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (__pyx_t_6) { + __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = NULL; + } + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_t_10); + __pyx_t_1 = 0; + __pyx_t_10 = 0; + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 268, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF_SET(__pyx_v_mask, __pyx_t_11); + __pyx_t_11 = 0; + + /* "detect.py":269 + * objtype = "Spacer" + * mask = np.zeros(gray.shape, np.uint8) + * cv2.drawContours(mask, [c], 0, 255, -1) # <<<<<<<<<<<<<< + * #pixelpoints = np.transpose(np.nonzero(mask)) + * hsv = cv2.cvtColor(orig, cv2.COLOR_BGR2HSV) + */ + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_cv2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 269, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_drawContours); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 269, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 269, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_c); + __Pyx_GIVEREF(__pyx_v_c); + PyList_SET_ITEM(__pyx_t_4, 0, __pyx_v_c); __pyx_t_10 = NULL; __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1); + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_10)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); + __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_t_6, __pyx_float_0_38, __pyx_float_0_03}; - __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 267, __pyx_L1_error) + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[6] = {__pyx_t_10, __pyx_v_mask, __pyx_t_4, __pyx_int_0, __pyx_int_255, __pyx_int_neg_1}; + __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 269, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_t_6, __pyx_float_0_38, __pyx_float_0_03}; - __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 267, __pyx_L1_error) + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[6] = {__pyx_t_10, __pyx_v_mask, __pyx_t_4, __pyx_int_0, __pyx_int_255, __pyx_int_neg_1}; + __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 269, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { - __pyx_t_4 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 267, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = PyTuple_New(5+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 269, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); if (__pyx_t_10) { - __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_10); __pyx_t_10 = NULL; + __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_10); __pyx_t_10 = NULL; } - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_9, __pyx_t_6); - __Pyx_INCREF(__pyx_float_0_38); - __Pyx_GIVEREF(__pyx_float_0_38); - PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_9, __pyx_float_0_38); - __Pyx_INCREF(__pyx_float_0_03); - __Pyx_GIVEREF(__pyx_float_0_03); - PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_9, __pyx_float_0_03); - __pyx_t_6 = 0; - __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 267, __pyx_L1_error) + __Pyx_INCREF(__pyx_v_mask); + __Pyx_GIVEREF(__pyx_v_mask); + PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_9, __pyx_v_mask); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_9, __pyx_t_4); + __Pyx_INCREF(__pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_9, __pyx_int_0); + __Pyx_INCREF(__pyx_int_255); + __Pyx_GIVEREF(__pyx_int_255); + PyTuple_SET_ITEM(__pyx_t_1, 3+__pyx_t_9, __pyx_int_255); + __Pyx_INCREF(__pyx_int_neg_1); + __Pyx_GIVEREF(__pyx_int_neg_1); + PyTuple_SET_ITEM(__pyx_t_1, 4+__pyx_t_9, __pyx_int_neg_1); + __pyx_t_4 = 0; + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 267, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_2 = __pyx_t_7; - __pyx_L65_bool_binop_done:; - if (__pyx_t_2) { - - /* "detect.py":269 - * if circular and near(radius * 2 / pixelsPerMetric, 0.38, 0.03): - * # Keps nut or spacer - * objtype = "Spacer" # <<<<<<<<<<<<<< - * mask = np.zeros(gray.shape, np.uint8) - * cv2.drawContours(mask, [c], 0, 255, -1) - */ - __Pyx_INCREF(__pyx_n_s_Spacer); - __Pyx_DECREF_SET(__pyx_v_objtype, __pyx_n_s_Spacer); - /* "detect.py":270 - * # Keps nut or spacer - * objtype = "Spacer" - * mask = np.zeros(gray.shape, np.uint8) # <<<<<<<<<<<<<< - * cv2.drawContours(mask, [c], 0, 255, -1) - * #pixelpoints = np.transpose(np.nonzero(mask)) + /* "detect.py":271 + * cv2.drawContours(mask, [c], 0, 255, -1) + * #pixelpoints = np.transpose(np.nonzero(mask)) + * hsv = cv2.cvtColor(orig, cv2.COLOR_BGR2HSV) # <<<<<<<<<<<<<< + * mean_val = cv2.mean(hsv, mask=mask) + * #print(str(mean_val[0])) */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 270, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_gray, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 270, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 270, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_1, __pyx_t_10}; - __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 270, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_1, __pyx_t_10}; - __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 270, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } else - #endif - { - __pyx_t_3 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 270, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (__pyx_t_6) { - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = NULL; - } - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_t_10); - __pyx_t_1 = 0; - __pyx_t_10 = 0; - __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 270, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_cv2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 271, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_cvtColor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 271, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_cv2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 271, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_COLOR_BGR2HSV); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 271, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = NULL; + __pyx_t_9 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + __pyx_t_9 = 1; } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_orig, __pyx_t_4}; + __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 271, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_XDECREF_SET(__pyx_v_mask, __pyx_t_11); - __pyx_t_11 = 0; - - /* "detect.py":271 - * objtype = "Spacer" - * mask = np.zeros(gray.shape, np.uint8) - * cv2.drawContours(mask, [c], 0, 255, -1) # <<<<<<<<<<<<<< - * #pixelpoints = np.transpose(np.nonzero(mask)) - * hsv = cv2.cvtColor(orig, cv2.COLOR_BGR2HSV) - */ - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_cv2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 271, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_drawContours); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 271, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_orig, __pyx_t_4}; + __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 271, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 271, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_INCREF(__pyx_v_c); - __Pyx_GIVEREF(__pyx_v_c); - PyList_SET_ITEM(__pyx_t_4, 0, __pyx_v_c); - __pyx_t_10 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_10)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_10); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - __pyx_t_9 = 1; - } + } else + #endif + { + __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 271, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + if (__pyx_t_3) { + __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3); __pyx_t_3 = NULL; } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[6] = {__pyx_t_10, __pyx_v_mask, __pyx_t_4, __pyx_int_0, __pyx_int_255, __pyx_int_neg_1}; - __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 271, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[6] = {__pyx_t_10, __pyx_v_mask, __pyx_t_4, __pyx_int_0, __pyx_int_255, __pyx_int_neg_1}; - __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 271, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - { - __pyx_t_1 = PyTuple_New(5+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 271, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (__pyx_t_10) { - __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_10); __pyx_t_10 = NULL; - } - __Pyx_INCREF(__pyx_v_mask); - __Pyx_GIVEREF(__pyx_v_mask); - PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_9, __pyx_v_mask); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_9, __pyx_t_4); - __Pyx_INCREF(__pyx_int_0); - __Pyx_GIVEREF(__pyx_int_0); - PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_9, __pyx_int_0); - __Pyx_INCREF(__pyx_int_255); - __Pyx_GIVEREF(__pyx_int_255); - PyTuple_SET_ITEM(__pyx_t_1, 3+__pyx_t_9, __pyx_int_255); - __Pyx_INCREF(__pyx_int_neg_1); - __Pyx_GIVEREF(__pyx_int_neg_1); - PyTuple_SET_ITEM(__pyx_t_1, 4+__pyx_t_9, __pyx_int_neg_1); - __pyx_t_4 = 0; - __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 271, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - - /* "detect.py":273 - * cv2.drawContours(mask, [c], 0, 255, -1) - * #pixelpoints = np.transpose(np.nonzero(mask)) - * hsv = cv2.cvtColor(orig, cv2.COLOR_BGR2HSV) # <<<<<<<<<<<<<< - * mean_val = cv2.mean(hsv, mask=mask) - * #print(str(mean_val[0])) - */ - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_cv2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 273, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_cvtColor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 273, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_cv2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 273, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_COLOR_BGR2HSV); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 273, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_orig, __pyx_t_4}; - __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 273, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_orig, __pyx_t_4}; - __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 273, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - { - __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 273, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - if (__pyx_t_3) { - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3); __pyx_t_3 = NULL; - } - __Pyx_INCREF(__pyx_v_orig); - __Pyx_GIVEREF(__pyx_v_orig); - PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_v_orig); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 273, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF_SET(__pyx_v_hsv, __pyx_t_11); - __pyx_t_11 = 0; - - /* "detect.py":274 - * #pixelpoints = np.transpose(np.nonzero(mask)) - * hsv = cv2.cvtColor(orig, cv2.COLOR_BGR2HSV) - * mean_val = cv2.mean(hsv, mask=mask) # <<<<<<<<<<<<<< - * #print(str(mean_val[0])) - * if near(mean_val[0], 47, 5) and near(mean_val[1], 70, 5) and near(mean_val[2], 78, 5): - */ - __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_cv2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 274, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_mean); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 274, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 274, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_INCREF(__pyx_v_hsv); - __Pyx_GIVEREF(__pyx_v_hsv); - PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_hsv); - __pyx_t_10 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 274, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_mask, __pyx_v_mask) < 0) __PYX_ERR(0, 274, __pyx_L1_error) - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_XDECREF_SET(__pyx_v_mean_val, __pyx_t_4); + __Pyx_INCREF(__pyx_v_orig); + __Pyx_GIVEREF(__pyx_v_orig); + PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_v_orig); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_4); __pyx_t_4 = 0; - - /* "detect.py":276 - * mean_val = cv2.mean(hsv, mask=mask) - * #print(str(mean_val[0])) - * if near(mean_val[0], 47, 5) and near(mean_val[1], 70, 5) and near(mean_val[2], 78, 5): # <<<<<<<<<<<<<< - * objtype = "Keps Nut" - * if circular and near(radius / pixelsPerMetric, 0.23, 0.02): - */ - __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_near); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_mean_val, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 271, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_1 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { - __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_10); - if (likely(__pyx_t_1)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); - __Pyx_INCREF(__pyx_t_1); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_10, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_10)) { - PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_11, __pyx_int_47, __pyx_int_5}; - __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { - PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_11, __pyx_int_47, __pyx_int_5}; - __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - } else - #endif - { - __pyx_t_3 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (__pyx_t_1) { - __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = NULL; - } - __Pyx_GIVEREF(__pyx_t_11); - PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_t_11); - __Pyx_INCREF(__pyx_int_47); - __Pyx_GIVEREF(__pyx_int_47); - PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_int_47); - __Pyx_INCREF(__pyx_int_5); - __Pyx_GIVEREF(__pyx_int_5); - PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_9, __pyx_int_5); - __pyx_t_11 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_7) { - } else { - __pyx_t_2 = __pyx_t_7; - goto __pyx_L68_bool_binop_done; - } - __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_near); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_mean_val, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_11 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { - __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10); - if (likely(__pyx_t_11)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); - __Pyx_INCREF(__pyx_t_11); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_10, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_10)) { - PyObject *__pyx_temp[4] = {__pyx_t_11, __pyx_t_3, __pyx_int_70, __pyx_int_5}; - __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { - PyObject *__pyx_temp[4] = {__pyx_t_11, __pyx_t_3, __pyx_int_70, __pyx_int_5}; - __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - { - __pyx_t_1 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (__pyx_t_11) { - __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_11); __pyx_t_11 = NULL; - } - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_9, __pyx_t_3); - __Pyx_INCREF(__pyx_int_70); - __Pyx_GIVEREF(__pyx_int_70); - PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_9, __pyx_int_70); - __Pyx_INCREF(__pyx_int_5); - __Pyx_GIVEREF(__pyx_int_5); - PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_9, __pyx_int_5); - __pyx_t_3 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_7) { - } else { - __pyx_t_2 = __pyx_t_7; - goto __pyx_L68_bool_binop_done; - } - __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_near); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_mean_val, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_10, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_10)) { - PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_t_1, __pyx_int_78, __pyx_int_5}; - __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { - PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_t_1, __pyx_int_78, __pyx_int_5}; - __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - #endif - { - __pyx_t_11 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - if (__pyx_t_3) { - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3); __pyx_t_3 = NULL; - } - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_9, __pyx_t_1); - __Pyx_INCREF(__pyx_int_78); - __Pyx_GIVEREF(__pyx_int_78); - PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_9, __pyx_int_78); - __Pyx_INCREF(__pyx_int_5); - __Pyx_GIVEREF(__pyx_int_5); - PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_9, __pyx_int_5); - __pyx_t_1 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_11, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - } - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_2 = __pyx_t_7; - __pyx_L68_bool_binop_done:; - if (__pyx_t_2) { - - /* "detect.py":277 - * #print(str(mean_val[0])) - * if near(mean_val[0], 47, 5) and near(mean_val[1], 70, 5) and near(mean_val[2], 78, 5): - * objtype = "Keps Nut" # <<<<<<<<<<<<<< - * if circular and near(radius / pixelsPerMetric, 0.23, 0.02): - * objtype = "Washer" - */ - __Pyx_INCREF(__pyx_kp_s_Keps_Nut); - __Pyx_DECREF_SET(__pyx_v_objtype, __pyx_kp_s_Keps_Nut); - - /* "detect.py":276 - * mean_val = cv2.mean(hsv, mask=mask) - * #print(str(mean_val[0])) - * if near(mean_val[0], 47, 5) and near(mean_val[1], 70, 5) and near(mean_val[2], 78, 5): # <<<<<<<<<<<<<< - * objtype = "Keps Nut" - * if circular and near(radius / pixelsPerMetric, 0.23, 0.02): - */ - } + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF_SET(__pyx_v_hsv, __pyx_t_11); + __pyx_t_11 = 0; - /* "detect.py":267 - * iteml = 0 - * else: - * if circular and near(radius * 2 / pixelsPerMetric, 0.38, 0.03): # <<<<<<<<<<<<<< - * # Keps nut or spacer - * objtype = "Spacer" + /* "detect.py":272 + * #pixelpoints = np.transpose(np.nonzero(mask)) + * hsv = cv2.cvtColor(orig, cv2.COLOR_BGR2HSV) + * mean_val = cv2.mean(hsv, mask=mask) # <<<<<<<<<<<<<< + * #print(str(mean_val[0])) + * if near(mean_val[0], 47, 5) and near(mean_val[1], 70, 5) and near(mean_val[2], 78, 5): */ - } + __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_cv2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 272, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_mean); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 272, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 272, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_INCREF(__pyx_v_hsv); + __Pyx_GIVEREF(__pyx_v_hsv); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_hsv); + __pyx_t_10 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 272, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_mask, __pyx_v_mask) < 0) __PYX_ERR(0, 272, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 272, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_XDECREF_SET(__pyx_v_mean_val, __pyx_t_4); + __pyx_t_4 = 0; - /* "detect.py":278 - * if near(mean_val[0], 47, 5) and near(mean_val[1], 70, 5) and near(mean_val[2], 78, 5): - * objtype = "Keps Nut" - * if circular and near(radius / pixelsPerMetric, 0.23, 0.02): # <<<<<<<<<<<<<< - * objtype = "Washer" - * epsilon = 3 # 0.02*cv2.arcLength(c,True) + /* "detect.py":274 + * mean_val = cv2.mean(hsv, mask=mask) + * #print(str(mean_val[0])) + * if near(mean_val[0], 47, 5) and near(mean_val[1], 70, 5) and near(mean_val[2], 78, 5): # <<<<<<<<<<<<<< + * objtype = "Keps Nut" + * if circular and near(radius / pixelsPerMetric, 0.23, 0.02): */ - __pyx_t_7 = (__pyx_v_circular != 0); - if (__pyx_t_7) { - } else { - __pyx_t_2 = __pyx_t_7; - goto __pyx_L72_bool_binop_done; - } - __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_near); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 278, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_near); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 274, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __pyx_t_11 = __Pyx_PyNumber_Divide(__pyx_v_radius, __pyx_v_pixelsPerMetric); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 278, __pyx_L1_error) + __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_mean_val, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 274, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_1 = NULL; __pyx_t_9 = 0; @@ -8052,8 +7802,8 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_10)) { - PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_11, __pyx_float_0_23, __pyx_float_0_02}; - __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 278, __pyx_L1_error) + PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_11, __pyx_int_47, __pyx_int_5}; + __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; @@ -8061,204 +7811,709 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { - PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_11, __pyx_float_0_23, __pyx_float_0_02}; - __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 278, __pyx_L1_error) + PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_11, __pyx_int_47, __pyx_int_5}; + __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } else #endif { - __pyx_t_3 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 274, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__pyx_t_1) { __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = NULL; } __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_t_11); - __Pyx_INCREF(__pyx_float_0_23); - __Pyx_GIVEREF(__pyx_float_0_23); - PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_float_0_23); - __Pyx_INCREF(__pyx_float_0_02); - __Pyx_GIVEREF(__pyx_float_0_02); - PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_9, __pyx_float_0_02); + __Pyx_INCREF(__pyx_int_47); + __Pyx_GIVEREF(__pyx_int_47); + PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_int_47); + __Pyx_INCREF(__pyx_int_5); + __Pyx_GIVEREF(__pyx_int_5); + PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_9, __pyx_int_5); __pyx_t_11 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 278, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 274, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_7) { + } else { + __pyx_t_2 = __pyx_t_7; + goto __pyx_L65_bool_binop_done; + } + __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_near); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 274, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_mean_val, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 274, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_11 = NULL; + __pyx_t_9 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { + __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10); + if (likely(__pyx_t_11)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); + __Pyx_INCREF(__pyx_t_11); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_10, function); + __pyx_t_9 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_10)) { + PyObject *__pyx_temp[4] = {__pyx_t_11, __pyx_t_3, __pyx_int_70, __pyx_int_5}; + __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { + PyObject *__pyx_temp[4] = {__pyx_t_11, __pyx_t_3, __pyx_int_70, __pyx_int_5}; + __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + { + __pyx_t_1 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 274, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (__pyx_t_11) { + __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_11); __pyx_t_11 = NULL; + } + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_9, __pyx_t_3); + __Pyx_INCREF(__pyx_int_70); + __Pyx_GIVEREF(__pyx_int_70); + PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_9, __pyx_int_70); + __Pyx_INCREF(__pyx_int_5); + __Pyx_GIVEREF(__pyx_int_5); + PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_9, __pyx_int_5); + __pyx_t_3 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 274, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_7) { + } else { + __pyx_t_2 = __pyx_t_7; + goto __pyx_L65_bool_binop_done; + } + __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_near); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 274, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_mean_val, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 274, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = NULL; + __pyx_t_9 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_10, function); + __pyx_t_9 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_10)) { + PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_t_1, __pyx_int_78, __pyx_int_5}; + __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { + PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_t_1, __pyx_int_78, __pyx_int_5}; + __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + #endif + { + __pyx_t_11 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 274, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + if (__pyx_t_3) { + __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3); __pyx_t_3 = NULL; + } + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_9, __pyx_t_1); + __Pyx_INCREF(__pyx_int_78); + __Pyx_GIVEREF(__pyx_int_78); + PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_9, __pyx_int_78); + __Pyx_INCREF(__pyx_int_5); + __Pyx_GIVEREF(__pyx_int_5); + PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_9, __pyx_int_5); + __pyx_t_1 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_11, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 274, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_2 = __pyx_t_7; + __pyx_L65_bool_binop_done:; + if (__pyx_t_2) { + + /* "detect.py":275 + * #print(str(mean_val[0])) + * if near(mean_val[0], 47, 5) and near(mean_val[1], 70, 5) and near(mean_val[2], 78, 5): + * objtype = "Keps Nut" # <<<<<<<<<<<<<< + * if circular and near(radius / pixelsPerMetric, 0.23, 0.02): + * objtype = "Washer" + */ + __Pyx_INCREF(__pyx_kp_s_Keps_Nut); + __Pyx_DECREF_SET(__pyx_v_objtype, __pyx_kp_s_Keps_Nut); + + /* "detect.py":274 + * mean_val = cv2.mean(hsv, mask=mask) + * #print(str(mean_val[0])) + * if near(mean_val[0], 47, 5) and near(mean_val[1], 70, 5) and near(mean_val[2], 78, 5): # <<<<<<<<<<<<<< + * objtype = "Keps Nut" + * if circular and near(radius / pixelsPerMetric, 0.23, 0.02): + */ + } + + /* "detect.py":265 + * iteml = 0 + * else: + * if circular and near(radius * 2 / pixelsPerMetric, 0.38, 0.03): # <<<<<<<<<<<<<< + * # Keps nut or spacer + * objtype = "Spacer" + */ + } + + /* "detect.py":276 + * if near(mean_val[0], 47, 5) and near(mean_val[1], 70, 5) and near(mean_val[2], 78, 5): + * objtype = "Keps Nut" + * if circular and near(radius / pixelsPerMetric, 0.23, 0.02): # <<<<<<<<<<<<<< + * objtype = "Washer" + * epsilon = 3 # 0.02*cv2.arcLength(c,True) + */ + __pyx_t_7 = (__pyx_v_circular != 0); + if (__pyx_t_7) { + } else { + __pyx_t_2 = __pyx_t_7; + goto __pyx_L69_bool_binop_done; + } + __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_near); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 276, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_11 = __Pyx_PyNumber_Divide(__pyx_v_radius, __pyx_v_pixelsPerMetric); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 276, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_1 = NULL; + __pyx_t_9 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { + __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_10); + if (likely(__pyx_t_1)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_10, function); + __pyx_t_9 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_10)) { + PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_11, __pyx_float_0_23, __pyx_float_0_02}; + __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { + PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_11, __pyx_float_0_23, __pyx_float_0_02}; + __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } else + #endif + { + __pyx_t_3 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (__pyx_t_1) { + __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = NULL; + } + __Pyx_GIVEREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_t_11); + __Pyx_INCREF(__pyx_float_0_23); + __Pyx_GIVEREF(__pyx_float_0_23); + PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_float_0_23); + __Pyx_INCREF(__pyx_float_0_02); + __Pyx_GIVEREF(__pyx_float_0_02); + PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_9, __pyx_float_0_02); + __pyx_t_11 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 276, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_2 = __pyx_t_7; + __pyx_L69_bool_binop_done:; + if (__pyx_t_2) { + + /* "detect.py":277 + * objtype = "Keps Nut" + * if circular and near(radius / pixelsPerMetric, 0.23, 0.02): + * objtype = "Washer" # <<<<<<<<<<<<<< + * epsilon = 3 # 0.02*cv2.arcLength(c,True) + * # print(str(epsilon)) + */ + __Pyx_INCREF(__pyx_n_s_Washer); + __Pyx_DECREF_SET(__pyx_v_objtype, __pyx_n_s_Washer); + + /* "detect.py":276 + * if near(mean_val[0], 47, 5) and near(mean_val[1], 70, 5) and near(mean_val[2], 78, 5): + * objtype = "Keps Nut" + * if circular and near(radius / pixelsPerMetric, 0.23, 0.02): # <<<<<<<<<<<<<< + * objtype = "Washer" + * epsilon = 3 # 0.02*cv2.arcLength(c,True) + */ + } + + /* "detect.py":278 + * if circular and near(radius / pixelsPerMetric, 0.23, 0.02): + * objtype = "Washer" + * epsilon = 3 # 0.02*cv2.arcLength(c,True) # <<<<<<<<<<<<<< + * # print(str(epsilon)) + * approx = cv2.approxPolyDP(c, epsilon, True) + */ + __pyx_v_epsilon = 3; + + /* "detect.py":280 + * epsilon = 3 # 0.02*cv2.arcLength(c,True) + * # print(str(epsilon)) + * approx = cv2.approxPolyDP(c, epsilon, True) # <<<<<<<<<<<<<< + * hull = cv2.convexHull(approx, returnPoints=False) + * hull2 = cv2.convexHull(c) + */ + __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_cv2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_approxPolyDP); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = __Pyx_PyInt_From_long(__pyx_v_epsilon); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_11 = NULL; + __pyx_t_9 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_11)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_11); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + __pyx_t_9 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[4] = {__pyx_t_11, __pyx_v_c, __pyx_t_10, Py_True}; + __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[4] = {__pyx_t_11, __pyx_v_c, __pyx_t_10, Py_True}; + __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } else + #endif + { + __pyx_t_1 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (__pyx_t_11) { + __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_11); __pyx_t_11 = NULL; + } + __Pyx_INCREF(__pyx_v_c); + __Pyx_GIVEREF(__pyx_v_c); + PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_9, __pyx_v_c); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_9, __pyx_t_10); + __Pyx_INCREF(Py_True); + __Pyx_GIVEREF(Py_True); + PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_9, Py_True); + __pyx_t_10 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 280, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF_SET(__pyx_v_approx, __pyx_t_4); + __pyx_t_4 = 0; + + /* "detect.py":281 + * # print(str(epsilon)) + * approx = cv2.approxPolyDP(c, epsilon, True) + * hull = cv2.convexHull(approx, returnPoints=False) # <<<<<<<<<<<<<< + * hull2 = cv2.convexHull(c) + * defects = cv2.convexityDefects(c, hull) + */ + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_cv2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 281, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_convexHull); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 281, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 281, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_approx); + __Pyx_GIVEREF(__pyx_v_approx); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_approx); + __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 281, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_returnPoints, Py_False) < 0) __PYX_ERR(0, 281, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 281, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF_SET(__pyx_v_hull, __pyx_t_10); + __pyx_t_10 = 0; + + /* "detect.py":282 + * approx = cv2.approxPolyDP(c, epsilon, True) + * hull = cv2.convexHull(approx, returnPoints=False) + * hull2 = cv2.convexHull(c) # <<<<<<<<<<<<<< + * defects = cv2.convexityDefects(c, hull) + * #print(str(defects.size) + " match") + */ + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_cv2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 282, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_convexHull); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 282, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_1)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + __pyx_t_10 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_v_c) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_c); + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 282, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF_SET(__pyx_v_hull2, __pyx_t_10); + __pyx_t_10 = 0; + + /* "detect.py":283 + * hull = cv2.convexHull(approx, returnPoints=False) + * hull2 = cv2.convexHull(c) + * defects = cv2.convexityDefects(c, hull) # <<<<<<<<<<<<<< + * #print(str(defects.size) + " match") + * cv2.drawContours(orig, (hull2), -1, (0, 0, 255), 3) + */ + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_cv2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 283, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_convexityDefects); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 283, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = NULL; + __pyx_t_9 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + __pyx_t_9 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_c, __pyx_v_hull}; + __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 283, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_10); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_c, __pyx_v_hull}; + __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 283, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_10); + } else + #endif + { + __pyx_t_3 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (__pyx_t_4) { + __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL; + } + __Pyx_INCREF(__pyx_v_c); + __Pyx_GIVEREF(__pyx_v_c); + PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_v_c); + __Pyx_INCREF(__pyx_v_hull); + __Pyx_GIVEREF(__pyx_v_hull); + PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_v_hull); + __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 283, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF_SET(__pyx_v_defects, __pyx_t_10); + __pyx_t_10 = 0; + + /* "detect.py":285 + * defects = cv2.convexityDefects(c, hull) + * #print(str(defects.size) + " match") + * cv2.drawContours(orig, (hull2), -1, (0, 0, 255), 3) # <<<<<<<<<<<<<< + * cv2.drawContours(orig, (approx), -1, (255, 0, 0), 3) + * convexness = area_contour / cv2.contourArea(hull2) + */ + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_cv2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_drawContours); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 285, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = NULL; + __pyx_t_9 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_1)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + __pyx_t_9 = 1; } - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 278, __pyx_L1_error) + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[6] = {__pyx_t_1, __pyx_v_orig, __pyx_v_hull2, __pyx_int_neg_1, __pyx_tuple__5, __pyx_int_3}; + __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 285, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_GOTREF(__pyx_t_10); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[6] = {__pyx_t_1, __pyx_v_orig, __pyx_v_hull2, __pyx_int_neg_1, __pyx_tuple__5, __pyx_int_3}; + __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 285, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_GOTREF(__pyx_t_10); + } else + #endif + { + __pyx_t_4 = PyTuple_New(5+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 285, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + if (__pyx_t_1) { + __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __pyx_t_1 = NULL; + } + __Pyx_INCREF(__pyx_v_orig); + __Pyx_GIVEREF(__pyx_v_orig); + PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_9, __pyx_v_orig); + __Pyx_INCREF(__pyx_v_hull2); + __Pyx_GIVEREF(__pyx_v_hull2); + PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_9, __pyx_v_hull2); + __Pyx_INCREF(__pyx_int_neg_1); + __Pyx_GIVEREF(__pyx_int_neg_1); + PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_9, __pyx_int_neg_1); + __Pyx_INCREF(__pyx_tuple__5); + __Pyx_GIVEREF(__pyx_tuple__5); + PyTuple_SET_ITEM(__pyx_t_4, 3+__pyx_t_9, __pyx_tuple__5); + __Pyx_INCREF(__pyx_int_3); + __Pyx_GIVEREF(__pyx_int_3); + PyTuple_SET_ITEM(__pyx_t_4, 4+__pyx_t_9, __pyx_int_3); + __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 285, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_2 = __pyx_t_7; - __pyx_L72_bool_binop_done:; - if (__pyx_t_2) { - - /* "detect.py":279 - * objtype = "Keps Nut" - * if circular and near(radius / pixelsPerMetric, 0.23, 0.02): - * objtype = "Washer" # <<<<<<<<<<<<<< - * epsilon = 3 # 0.02*cv2.arcLength(c,True) - * # print(str(epsilon)) - */ - __Pyx_INCREF(__pyx_n_s_Washer); - __Pyx_DECREF_SET(__pyx_v_objtype, __pyx_n_s_Washer); + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - /* "detect.py":278 - * if near(mean_val[0], 47, 5) and near(mean_val[1], 70, 5) and near(mean_val[2], 78, 5): - * objtype = "Keps Nut" - * if circular and near(radius / pixelsPerMetric, 0.23, 0.02): # <<<<<<<<<<<<<< - * objtype = "Washer" - * epsilon = 3 # 0.02*cv2.arcLength(c,True) + /* "detect.py":286 + * #print(str(defects.size) + " match") + * cv2.drawContours(orig, (hull2), -1, (0, 0, 255), 3) + * cv2.drawContours(orig, (approx), -1, (255, 0, 0), 3) # <<<<<<<<<<<<<< + * convexness = area_contour / cv2.contourArea(hull2) + * #print(str(convexness) + " % fill") */ + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_cv2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_drawContours); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 286, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = NULL; + __pyx_t_9 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_9 = 1; } - - /* "detect.py":280 - * if circular and near(radius / pixelsPerMetric, 0.23, 0.02): - * objtype = "Washer" - * epsilon = 3 # 0.02*cv2.arcLength(c,True) # <<<<<<<<<<<<<< - * # print(str(epsilon)) - * approx = cv2.approxPolyDP(c, epsilon, True) - */ - __pyx_v_epsilon = 3; - - /* "detect.py":282 - * epsilon = 3 # 0.02*cv2.arcLength(c,True) - * # print(str(epsilon)) - * approx = cv2.approxPolyDP(c, epsilon, True) # <<<<<<<<<<<<<< - * hull = cv2.convexHull(approx, returnPoints=False) - * hull2 = cv2.convexHull(c) - */ - __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_cv2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 282, __pyx_L1_error) + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_v_orig, __pyx_v_approx, __pyx_int_neg_1, __pyx_tuple__4, __pyx_int_3}; + __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 286, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_10); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_approxPolyDP); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 282, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = __Pyx_PyInt_From_long(__pyx_v_epsilon); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 282, __pyx_L1_error) + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_v_orig, __pyx_v_approx, __pyx_int_neg_1, __pyx_tuple__4, __pyx_int_3}; + __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 286, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_10); - __pyx_t_11 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_11)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_11); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[4] = {__pyx_t_11, __pyx_v_c, __pyx_t_10, Py_True}; - __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 282, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[4] = {__pyx_t_11, __pyx_v_c, __pyx_t_10, Py_True}; - __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 282, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } else - #endif - { - __pyx_t_1 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 282, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (__pyx_t_11) { - __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_11); __pyx_t_11 = NULL; - } - __Pyx_INCREF(__pyx_v_c); - __Pyx_GIVEREF(__pyx_v_c); - PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_9, __pyx_v_c); - __Pyx_GIVEREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_9, __pyx_t_10); - __Pyx_INCREF(Py_True); - __Pyx_GIVEREF(Py_True); - PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_9, Py_True); - __pyx_t_10 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 282, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + #endif + { + __pyx_t_1 = PyTuple_New(5+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (__pyx_t_3) { + __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); __pyx_t_3 = NULL; } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_XDECREF_SET(__pyx_v_approx, __pyx_t_4); - __pyx_t_4 = 0; - - /* "detect.py":283 - * # print(str(epsilon)) - * approx = cv2.approxPolyDP(c, epsilon, True) - * hull = cv2.convexHull(approx, returnPoints=False) # <<<<<<<<<<<<<< - * hull2 = cv2.convexHull(c) - * defects = cv2.convexityDefects(c, hull) - */ - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_cv2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 283, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_convexHull); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 283, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_orig); + __Pyx_GIVEREF(__pyx_v_orig); + PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_9, __pyx_v_orig); __Pyx_INCREF(__pyx_v_approx); __Pyx_GIVEREF(__pyx_v_approx); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_approx); - __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 283, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_returnPoints, Py_False) < 0) __PYX_ERR(0, 283, __pyx_L1_error) - __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 283, __pyx_L1_error) + PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_9, __pyx_v_approx); + __Pyx_INCREF(__pyx_int_neg_1); + __Pyx_GIVEREF(__pyx_int_neg_1); + PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_9, __pyx_int_neg_1); + __Pyx_INCREF(__pyx_tuple__4); + __Pyx_GIVEREF(__pyx_tuple__4); + PyTuple_SET_ITEM(__pyx_t_1, 3+__pyx_t_9, __pyx_tuple__4); + __Pyx_INCREF(__pyx_int_3); + __Pyx_GIVEREF(__pyx_int_3); + PyTuple_SET_ITEM(__pyx_t_1, 4+__pyx_t_9, __pyx_int_3); + __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF_SET(__pyx_v_hull, __pyx_t_10); - __pyx_t_10 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - /* "detect.py":284 - * approx = cv2.approxPolyDP(c, epsilon, True) - * hull = cv2.convexHull(approx, returnPoints=False) - * hull2 = cv2.convexHull(c) # <<<<<<<<<<<<<< - * defects = cv2.convexityDefects(c, hull) - * #print(str(defects.size) + " match") + /* "detect.py":287 + * cv2.drawContours(orig, (hull2), -1, (0, 0, 255), 3) + * cv2.drawContours(orig, (approx), -1, (255, 0, 0), 3) + * convexness = area_contour / cv2.contourArea(hull2) # <<<<<<<<<<<<<< + * #print(str(convexness) + " % fill") + * # if not cv2.isContourConvex(approx): */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_cv2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 284, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_convexHull); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 284, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_1)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_1); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - } + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_cv2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 287, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_contourArea); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); } - __pyx_t_10 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_v_c) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_c); - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 284, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_XDECREF_SET(__pyx_v_hull2, __pyx_t_10); - __pyx_t_10 = 0; + } + __pyx_t_10 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_hull2) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_hull2); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 287, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_v_area_contour, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_XDECREF_SET(__pyx_v_convexness, __pyx_t_1); + __pyx_t_1 = 0; - /* "detect.py":285 - * hull = cv2.convexHull(approx, returnPoints=False) - * hull2 = cv2.convexHull(c) - * defects = cv2.convexityDefects(c, hull) # <<<<<<<<<<<<<< - * #print(str(defects.size) + " match") - * cv2.drawContours(orig, (hull2), -1, (0, 0, 255), 3) + /* "detect.py":291 + * # if not cv2.isContourConvex(approx): + * # if cv2.matchShapes(hull, c, 1, 0.0) > 1: + * if defects is not None and defects.size > 5 and (convexness < 0.9 or boxiness < 0.75) and rectangular: # <<<<<<<<<<<<<< + * objtype = "Screw" + * iteml = larger(dimA, dimB) */ - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_cv2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 285, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_convexityDefects); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error) + __pyx_t_7 = (__pyx_v_defects != Py_None); + __pyx_t_8 = (__pyx_t_7 != 0); + if (__pyx_t_8) { + } else { + __pyx_t_2 = __pyx_t_8; + goto __pyx_L72_bool_binop_done; + } + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_defects, __pyx_n_s_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 291, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_10 = PyObject_RichCompare(__pyx_t_1, __pyx_int_5, Py_GT); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 291, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 291, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + if (__pyx_t_8) { + } else { + __pyx_t_2 = __pyx_t_8; + goto __pyx_L72_bool_binop_done; + } + __pyx_t_10 = PyObject_RichCompare(__pyx_v_convexness, __pyx_float_0_9, Py_LT); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 291, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + if (!__pyx_t_8) { + } else { + goto __pyx_L75_next_and; + } + __pyx_t_10 = PyObject_RichCompare(__pyx_v_boxiness, __pyx_float_0_75, Py_LT); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 291, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + if (__pyx_t_8) { + } else { + __pyx_t_2 = __pyx_t_8; + goto __pyx_L72_bool_binop_done; + } + __pyx_L75_next_and:; + __pyx_t_8 = (__pyx_v_rectangular != 0); + __pyx_t_2 = __pyx_t_8; + __pyx_L72_bool_binop_done:; + if (__pyx_t_2) { + + /* "detect.py":292 + * # if cv2.matchShapes(hull, c, 1, 0.0) > 1: + * if defects is not None and defects.size > 5 and (convexness < 0.9 or boxiness < 0.75) and rectangular: + * objtype = "Screw" # <<<<<<<<<<<<<< + * iteml = larger(dimA, dimB) + * #print("Screw Length (RAW): " + str(iteml)) + */ + __Pyx_INCREF(__pyx_n_s_Screw); + __Pyx_DECREF_SET(__pyx_v_objtype, __pyx_n_s_Screw); + + /* "detect.py":293 + * if defects is not None and defects.size > 5 and (convexness < 0.9 or boxiness < 0.75) and rectangular: + * objtype = "Screw" + * iteml = larger(dimA, dimB) # <<<<<<<<<<<<<< + * #print("Screw Length (RAW): " + str(iteml)) + * iteml = sizeVexScrew(radius * 2 / pixelsPerMetric) + */ + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_larger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 293, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { @@ -8273,276 +8528,125 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_c, __pyx_v_hull}; - __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 285, __pyx_L1_error) + PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_dimA, __pyx_v_dimB}; + __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 293, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_10); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_c, __pyx_v_hull}; - __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 285, __pyx_L1_error) + PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_dimA, __pyx_v_dimB}; + __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 293, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_10); } else #endif { - __pyx_t_3 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 285, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 293, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL; } - __Pyx_INCREF(__pyx_v_c); - __Pyx_GIVEREF(__pyx_v_c); - PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_v_c); - __Pyx_INCREF(__pyx_v_hull); - __Pyx_GIVEREF(__pyx_v_hull); - PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_v_hull); - __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 285, __pyx_L1_error) + __Pyx_INCREF(__pyx_v_dimA); + __Pyx_GIVEREF(__pyx_v_dimA); + PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_v_dimA); + __Pyx_INCREF(__pyx_v_dimB); + __Pyx_GIVEREF(__pyx_v_dimB); + PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_v_dimB); + __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 293, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF_SET(__pyx_v_defects, __pyx_t_10); + __Pyx_XDECREF_SET(__pyx_v_iteml, __pyx_t_10); __pyx_t_10 = 0; - /* "detect.py":287 - * defects = cv2.convexityDefects(c, hull) - * #print(str(defects.size) + " match") - * cv2.drawContours(orig, (hull2), -1, (0, 0, 255), 3) # <<<<<<<<<<<<<< - * cv2.drawContours(orig, (approx), -1, (255, 0, 0), 3) - * convexness = area_contour / cv2.contourArea(hull2) + /* "detect.py":295 + * iteml = larger(dimA, dimB) + * #print("Screw Length (RAW): " + str(iteml)) + * iteml = sizeVexScrew(radius * 2 / pixelsPerMetric) # <<<<<<<<<<<<<< + * #print("Rounded Length: " + str(iteml)) + * else: */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_cv2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_sizeVexScrew); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 295, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_drawContours); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 287, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_1)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_1); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[6] = {__pyx_t_1, __pyx_v_orig, __pyx_v_hull2, __pyx_int_neg_1, __pyx_tuple__5, __pyx_int_3}; - __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 287, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GOTREF(__pyx_t_10); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[6] = {__pyx_t_1, __pyx_v_orig, __pyx_v_hull2, __pyx_int_neg_1, __pyx_tuple__5, __pyx_int_3}; - __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 287, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GOTREF(__pyx_t_10); - } else - #endif - { - __pyx_t_4 = PyTuple_New(5+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 287, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - if (__pyx_t_1) { - __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __pyx_t_1 = NULL; - } - __Pyx_INCREF(__pyx_v_orig); - __Pyx_GIVEREF(__pyx_v_orig); - PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_9, __pyx_v_orig); - __Pyx_INCREF(__pyx_v_hull2); - __Pyx_GIVEREF(__pyx_v_hull2); - PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_9, __pyx_v_hull2); - __Pyx_INCREF(__pyx_int_neg_1); - __Pyx_GIVEREF(__pyx_int_neg_1); - PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_9, __pyx_int_neg_1); - __Pyx_INCREF(__pyx_tuple__5); - __Pyx_GIVEREF(__pyx_tuple__5); - PyTuple_SET_ITEM(__pyx_t_4, 3+__pyx_t_9, __pyx_tuple__5); - __Pyx_INCREF(__pyx_int_3); - __Pyx_GIVEREF(__pyx_int_3); - PyTuple_SET_ITEM(__pyx_t_4, 4+__pyx_t_9, __pyx_int_3); - __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 287, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - - /* "detect.py":288 - * #print(str(defects.size) + " match") - * cv2.drawContours(orig, (hull2), -1, (0, 0, 255), 3) - * cv2.drawContours(orig, (approx), -1, (255, 0, 0), 3) # <<<<<<<<<<<<<< - * convexness = area_contour / cv2.contourArea(hull2) - * #print(str(convexness) + " % fill") - */ - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_cv2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 288, __pyx_L1_error) + __pyx_t_3 = PyNumber_Multiply(__pyx_v_radius, __pyx_int_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 295, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_drawContours); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 288, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_v_pixelsPerMetric); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 295, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_v_orig, __pyx_v_approx, __pyx_int_neg_1, __pyx_tuple__4, __pyx_int_3}; - __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 288, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_10); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_v_orig, __pyx_v_approx, __pyx_int_neg_1, __pyx_tuple__4, __pyx_int_3}; - __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 288, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_10); - } else - #endif - { - __pyx_t_1 = PyTuple_New(5+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 288, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (__pyx_t_3) { - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); __pyx_t_3 = NULL; - } - __Pyx_INCREF(__pyx_v_orig); - __Pyx_GIVEREF(__pyx_v_orig); - PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_9, __pyx_v_orig); - __Pyx_INCREF(__pyx_v_approx); - __Pyx_GIVEREF(__pyx_v_approx); - PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_9, __pyx_v_approx); - __Pyx_INCREF(__pyx_int_neg_1); - __Pyx_GIVEREF(__pyx_int_neg_1); - PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_9, __pyx_int_neg_1); - __Pyx_INCREF(__pyx_tuple__4); - __Pyx_GIVEREF(__pyx_tuple__4); - PyTuple_SET_ITEM(__pyx_t_1, 3+__pyx_t_9, __pyx_tuple__4); - __Pyx_INCREF(__pyx_int_3); - __Pyx_GIVEREF(__pyx_int_3); - PyTuple_SET_ITEM(__pyx_t_1, 4+__pyx_t_9, __pyx_int_3); - __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 288, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - - /* "detect.py":289 - * cv2.drawContours(orig, (hull2), -1, (0, 0, 255), 3) - * cv2.drawContours(orig, (approx), -1, (255, 0, 0), 3) - * convexness = area_contour / cv2.contourArea(hull2) # <<<<<<<<<<<<<< - * #print(str(convexness) + " % fill") - * # if not cv2.isContourConvex(approx): - */ - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_cv2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 289, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_contourArea); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 289, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_4)) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } - __pyx_t_10 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_hull2) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_hull2); - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 289, __pyx_L1_error) + __pyx_t_10 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 295, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_v_area_contour, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 289, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_XDECREF_SET(__pyx_v_convexness, __pyx_t_1); - __pyx_t_1 = 0; + __Pyx_DECREF_SET(__pyx_v_iteml, __pyx_t_10); + __pyx_t_10 = 0; - /* "detect.py":293 - * # if not cv2.isContourConvex(approx): - * # if cv2.matchShapes(hull, c, 1, 0.0) > 1: - * if defects is not None and defects.size > 5 and (convexness < 0.9 or boxiness < 0.75) and rectangular: # <<<<<<<<<<<<<< - * objtype = "Screw" - * iteml = larger(dimA, dimB) - */ - __pyx_t_7 = (__pyx_v_defects != Py_None); - __pyx_t_8 = (__pyx_t_7 != 0); - if (__pyx_t_8) { - } else { - __pyx_t_2 = __pyx_t_8; - goto __pyx_L75_bool_binop_done; - } - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_defects, __pyx_n_s_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 293, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = PyObject_RichCompare(__pyx_t_1, __pyx_int_5, Py_GT); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 293, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 293, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - if (__pyx_t_8) { - } else { - __pyx_t_2 = __pyx_t_8; - goto __pyx_L75_bool_binop_done; - } - __pyx_t_10 = PyObject_RichCompare(__pyx_v_convexness, __pyx_float_0_9, Py_LT); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 293, __pyx_L1_error) - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 293, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - if (!__pyx_t_8) { - } else { - goto __pyx_L78_next_and; - } - __pyx_t_10 = PyObject_RichCompare(__pyx_v_boxiness, __pyx_float_0_75, Py_LT); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 293, __pyx_L1_error) - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 293, __pyx_L1_error) + /* "detect.py":291 + * # if not cv2.isContourConvex(approx): + * # if cv2.matchShapes(hull, c, 1, 0.0) > 1: + * if defects is not None and defects.size > 5 and (convexness < 0.9 or boxiness < 0.75) and rectangular: # <<<<<<<<<<<<<< + * objtype = "Screw" + * iteml = larger(dimA, dimB) + */ + goto __pyx_L71; + } + + /* "detect.py":298 + * #print("Rounded Length: " + str(iteml)) + * else: + * if itemhr == 0.3125 and rectangular: # <<<<<<<<<<<<<< + * objtype = "Standoff" + * iteml = sizeStandoff(itemw) + */ + /*else*/ { + __pyx_t_10 = __Pyx_PyFloat_EqObjC(__pyx_v_itemhr, __pyx_float_0_3125, 0.3125, 0, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 298, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (__pyx_t_8) { } else { __pyx_t_2 = __pyx_t_8; - goto __pyx_L75_bool_binop_done; + goto __pyx_L78_bool_binop_done; } - __pyx_L78_next_and:; __pyx_t_8 = (__pyx_v_rectangular != 0); __pyx_t_2 = __pyx_t_8; - __pyx_L75_bool_binop_done:; + __pyx_L78_bool_binop_done:; if (__pyx_t_2) { - /* "detect.py":294 - * # if cv2.matchShapes(hull, c, 1, 0.0) > 1: - * if defects is not None and defects.size > 5 and (convexness < 0.9 or boxiness < 0.75) and rectangular: - * objtype = "Screw" # <<<<<<<<<<<<<< - * iteml = larger(dimA, dimB) - * #print("Screw Length (RAW): " + str(iteml)) - */ - __Pyx_INCREF(__pyx_n_s_Screw); - __Pyx_DECREF_SET(__pyx_v_objtype, __pyx_n_s_Screw); - - /* "detect.py":295 - * if defects is not None and defects.size > 5 and (convexness < 0.9 or boxiness < 0.75) and rectangular: - * objtype = "Screw" - * iteml = larger(dimA, dimB) # <<<<<<<<<<<<<< - * #print("Screw Length (RAW): " + str(iteml)) - * iteml = sizeVexScrew(radius * 2 / pixelsPerMetric) - */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_larger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 295, __pyx_L1_error) + /* "detect.py":299 + * else: + * if itemhr == 0.3125 and rectangular: + * objtype = "Standoff" # <<<<<<<<<<<<<< + * iteml = sizeStandoff(itemw) + * if itemhr == 0.1875 and rectangular: + */ + __Pyx_INCREF(__pyx_n_s_Standoff); + __Pyx_DECREF_SET(__pyx_v_objtype, __pyx_n_s_Standoff); + + /* "detect.py":300 + * if itemhr == 0.3125 and rectangular: + * objtype = "Standoff" + * iteml = sizeStandoff(itemw) # <<<<<<<<<<<<<< + * if itemhr == 0.1875 and rectangular: + * objtype = "Axle" + */ + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_sizeStandoff); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 300, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; - __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { @@ -8550,606 +8654,723 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_dimA, __pyx_v_dimB}; - __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 295, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_10); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_dimA, __pyx_v_dimB}; - __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 295, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_10); - } else - #endif - { - __pyx_t_3 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 295, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (__pyx_t_4) { - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL; } - __Pyx_INCREF(__pyx_v_dimA); - __Pyx_GIVEREF(__pyx_v_dimA); - PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_v_dimA); - __Pyx_INCREF(__pyx_v_dimB); - __Pyx_GIVEREF(__pyx_v_dimB); - PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_v_dimB); - __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 295, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } + __pyx_t_10 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_itemw) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_itemw); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 300, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF_SET(__pyx_v_iteml, __pyx_t_10); __pyx_t_10 = 0; - /* "detect.py":297 - * iteml = larger(dimA, dimB) - * #print("Screw Length (RAW): " + str(iteml)) - * iteml = sizeVexScrew(radius * 2 / pixelsPerMetric) # <<<<<<<<<<<<<< - * #print("Rounded Length: " + str(iteml)) - * else: + /* "detect.py":298 + * #print("Rounded Length: " + str(iteml)) + * else: + * if itemhr == 0.3125 and rectangular: # <<<<<<<<<<<<<< + * objtype = "Standoff" + * iteml = sizeStandoff(itemw) + */ + } + + /* "detect.py":301 + * objtype = "Standoff" + * iteml = sizeStandoff(itemw) + * if itemhr == 0.1875 and rectangular: # <<<<<<<<<<<<<< + * objtype = "Axle" + * iteml = (radius * 2 / pixelsPerMetric + itemw) / 2 + */ + __pyx_t_10 = __Pyx_PyFloat_EqObjC(__pyx_v_itemhr, __pyx_float_0_1875, 0.1875, 0, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 301, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 301, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + if (__pyx_t_8) { + } else { + __pyx_t_2 = __pyx_t_8; + goto __pyx_L81_bool_binop_done; + } + __pyx_t_8 = (__pyx_v_rectangular != 0); + __pyx_t_2 = __pyx_t_8; + __pyx_L81_bool_binop_done:; + if (__pyx_t_2) { + + /* "detect.py":302 + * iteml = sizeStandoff(itemw) + * if itemhr == 0.1875 and rectangular: + * objtype = "Axle" # <<<<<<<<<<<<<< + * iteml = (radius * 2 / pixelsPerMetric + itemw) / 2 + * rows, cols = orig.shape[:2] + */ + __Pyx_INCREF(__pyx_n_s_Axle); + __Pyx_DECREF_SET(__pyx_v_objtype, __pyx_n_s_Axle); + + /* "detect.py":303 + * if itemhr == 0.1875 and rectangular: + * objtype = "Axle" + * iteml = (radius * 2 / pixelsPerMetric + itemw) / 2 # <<<<<<<<<<<<<< + * rows, cols = orig.shape[:2] + * [vx, vy, xx, yy] = cv2.fitLine(c, cv2.DIST_L2, 0, 0.01, 0.01) */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_sizeVexScrew); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 297, __pyx_L1_error) + __pyx_t_10 = PyNumber_Multiply(__pyx_v_radius, __pyx_int_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 303, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_10, __pyx_v_pixelsPerMetric); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyNumber_Multiply(__pyx_v_radius, __pyx_int_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 297, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_v_pixelsPerMetric); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 297, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - __pyx_t_10 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 297, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = PyNumber_Add(__pyx_t_1, __pyx_v_itemw); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF_SET(__pyx_v_iteml, __pyx_t_10); - __pyx_t_10 = 0; + __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_10, __pyx_int_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 303, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_XDECREF_SET(__pyx_v_iteml, __pyx_t_1); + __pyx_t_1 = 0; - /* "detect.py":293 - * # if not cv2.isContourConvex(approx): - * # if cv2.matchShapes(hull, c, 1, 0.0) > 1: - * if defects is not None and defects.size > 5 and (convexness < 0.9 or boxiness < 0.75) and rectangular: # <<<<<<<<<<<<<< - * objtype = "Screw" - * iteml = larger(dimA, dimB) + /* "detect.py":301 + * objtype = "Standoff" + * iteml = sizeStandoff(itemw) + * if itemhr == 0.1875 and rectangular: # <<<<<<<<<<<<<< + * objtype = "Axle" + * iteml = (radius * 2 / pixelsPerMetric + itemw) / 2 */ - goto __pyx_L74; } + } + __pyx_L71:; + } + __pyx_L58:; - /* "detect.py":300 - * #print("Rounded Length: " + str(iteml)) - * else: - * if itemhr == 0.3125 and rectangular: # <<<<<<<<<<<<<< - * objtype = "Standoff" - * iteml = sizeStandoff(itemw) + /* "detect.py":304 + * objtype = "Axle" + * iteml = (radius * 2 / pixelsPerMetric + itemw) / 2 + * rows, cols = orig.shape[:2] # <<<<<<<<<<<<<< + * [vx, vy, xx, yy] = cv2.fitLine(c, cv2.DIST_L2, 0, 0.01, 0.01) + * lefty = int((-xx*vy/vx) + yy) */ - /*else*/ { - __pyx_t_10 = __Pyx_PyFloat_EqObjC(__pyx_v_itemhr, __pyx_float_0_3125, 0.3125, 0, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 300, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 300, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - if (__pyx_t_8) { - } else { - __pyx_t_2 = __pyx_t_8; - goto __pyx_L81_bool_binop_done; - } - __pyx_t_8 = (__pyx_v_rectangular != 0); - __pyx_t_2 = __pyx_t_8; - __pyx_L81_bool_binop_done:; - if (__pyx_t_2) { - - /* "detect.py":301 - * else: - * if itemhr == 0.3125 and rectangular: - * objtype = "Standoff" # <<<<<<<<<<<<<< - * iteml = sizeStandoff(itemw) - * - */ - __Pyx_INCREF(__pyx_n_s_Standoff); - __Pyx_DECREF_SET(__pyx_v_objtype, __pyx_n_s_Standoff); - - /* "detect.py":302 - * if itemhr == 0.3125 and rectangular: - * objtype = "Standoff" - * iteml = sizeStandoff(itemw) # <<<<<<<<<<<<<< - * - * if itemhr == 0.1875 and rectangular: - */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_sizeStandoff); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 302, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - __pyx_t_10 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_itemw) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_itemw); - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 302, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF_SET(__pyx_v_iteml, __pyx_t_10); - __pyx_t_10 = 0; - - /* "detect.py":300 - * #print("Rounded Length: " + str(iteml)) - * else: - * if itemhr == 0.3125 and rectangular: # <<<<<<<<<<<<<< - * objtype = "Standoff" - * iteml = sizeStandoff(itemw) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_orig, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 304, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_10 = __Pyx_PyObject_GetSlice(__pyx_t_1, 0, 2, NULL, NULL, &__pyx_slice__6, 0, 1, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 304, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if ((likely(PyTuple_CheckExact(__pyx_t_10))) || (PyList_CheckExact(__pyx_t_10))) { + PyObject* sequence = __pyx_t_10; + Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(0, 304, __pyx_L1_error) + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); + } else { + __pyx_t_1 = PyList_GET_ITEM(sequence, 0); + __pyx_t_4 = PyList_GET_ITEM(sequence, 1); + } + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(__pyx_t_4); + #else + __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 304, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 304, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + #endif + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } else { + Py_ssize_t index = -1; + __pyx_t_3 = PyObject_GetIter(__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 304, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_14 = Py_TYPE(__pyx_t_3)->tp_iternext; + index = 0; __pyx_t_1 = __pyx_t_14(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L83_unpacking_failed; + __Pyx_GOTREF(__pyx_t_1); + index = 1; __pyx_t_4 = __pyx_t_14(__pyx_t_3); if (unlikely(!__pyx_t_4)) goto __pyx_L83_unpacking_failed; + __Pyx_GOTREF(__pyx_t_4); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_3), 2) < 0) __PYX_ERR(0, 304, __pyx_L1_error) + __pyx_t_14 = NULL; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L84_unpacking_done; + __pyx_L83_unpacking_failed:; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_14 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + __PYX_ERR(0, 304, __pyx_L1_error) + __pyx_L84_unpacking_done:; + } + __Pyx_XDECREF_SET(__pyx_v_rows, __pyx_t_1); + __pyx_t_1 = 0; + __Pyx_XDECREF_SET(__pyx_v_cols, __pyx_t_4); + __pyx_t_4 = 0; + + /* "detect.py":305 + * iteml = (radius * 2 / pixelsPerMetric + itemw) / 2 + * rows, cols = orig.shape[:2] + * [vx, vy, xx, yy] = cv2.fitLine(c, cv2.DIST_L2, 0, 0.01, 0.01) # <<<<<<<<<<<<<< + * lefty = int((-xx*vy/vx) + yy) + * righty = int(((cols-xx)*vy/vx)+yy) */ - } + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_cv2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 305, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_fitLine); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_cv2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 305, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_DIST_L2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 305, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = NULL; + __pyx_t_9 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + __pyx_t_9 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[6] = {__pyx_t_4, __pyx_v_c, __pyx_t_3, __pyx_int_0, __pyx_float_0_01, __pyx_float_0_01}; + __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 305, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[6] = {__pyx_t_4, __pyx_v_c, __pyx_t_3, __pyx_int_0, __pyx_float_0_01, __pyx_float_0_01}; + __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 305, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + { + __pyx_t_11 = PyTuple_New(5+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 305, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + if (__pyx_t_4) { + __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4); __pyx_t_4 = NULL; + } + __Pyx_INCREF(__pyx_v_c); + __Pyx_GIVEREF(__pyx_v_c); + PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_9, __pyx_v_c); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_9, __pyx_t_3); + __Pyx_INCREF(__pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_9, __pyx_int_0); + __Pyx_INCREF(__pyx_float_0_01); + __Pyx_GIVEREF(__pyx_float_0_01); + PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_9, __pyx_float_0_01); + __Pyx_INCREF(__pyx_float_0_01); + __Pyx_GIVEREF(__pyx_float_0_01); + PyTuple_SET_ITEM(__pyx_t_11, 4+__pyx_t_9, __pyx_float_0_01); + __pyx_t_3 = 0; + __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 305, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if ((likely(PyTuple_CheckExact(__pyx_t_10))) || (PyList_CheckExact(__pyx_t_10))) { + PyObject* sequence = __pyx_t_10; + Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); + if (unlikely(size != 4)) { + if (size > 4) __Pyx_RaiseTooManyValuesError(4); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(0, 305, __pyx_L1_error) + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 3); + } else { + __pyx_t_1 = PyList_GET_ITEM(sequence, 0); + __pyx_t_11 = PyList_GET_ITEM(sequence, 1); + __pyx_t_3 = PyList_GET_ITEM(sequence, 2); + __pyx_t_4 = PyList_GET_ITEM(sequence, 3); + } + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(__pyx_t_11); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + #else + { + Py_ssize_t i; + PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_11,&__pyx_t_3,&__pyx_t_4}; + for (i=0; i < 4; i++) { + PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 305, __pyx_L1_error) + __Pyx_GOTREF(item); + *(temps[i]) = item; + } + } + #endif + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } else { + Py_ssize_t index = -1; + PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_11,&__pyx_t_3,&__pyx_t_4}; + __pyx_t_6 = PyObject_GetIter(__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 305, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_14 = Py_TYPE(__pyx_t_6)->tp_iternext; + for (index=0; index < 4; index++) { + PyObject* item = __pyx_t_14(__pyx_t_6); if (unlikely(!item)) goto __pyx_L85_unpacking_failed; + __Pyx_GOTREF(item); + *(temps[index]) = item; + } + if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_6), 4) < 0) __PYX_ERR(0, 305, __pyx_L1_error) + __pyx_t_14 = NULL; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + goto __pyx_L86_unpacking_done; + __pyx_L85_unpacking_failed:; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_14 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + __PYX_ERR(0, 305, __pyx_L1_error) + __pyx_L86_unpacking_done:; + } + __Pyx_XDECREF_SET(__pyx_v_vx, __pyx_t_1); + __pyx_t_1 = 0; + __Pyx_XDECREF_SET(__pyx_v_vy, __pyx_t_11); + __pyx_t_11 = 0; + __Pyx_XDECREF_SET(__pyx_v_xx, __pyx_t_3); + __pyx_t_3 = 0; + __Pyx_XDECREF_SET(__pyx_v_yy, __pyx_t_4); + __pyx_t_4 = 0; - /* "detect.py":304 - * iteml = sizeStandoff(itemw) - * - * if itemhr == 0.1875 and rectangular: # <<<<<<<<<<<<<< - * objtype = "Axle" - * iteml = (radius * 2 / pixelsPerMetric + itemw) / 2 + /* "detect.py":306 + * rows, cols = orig.shape[:2] + * [vx, vy, xx, yy] = cv2.fitLine(c, cv2.DIST_L2, 0, 0.01, 0.01) + * lefty = int((-xx*vy/vx) + yy) # <<<<<<<<<<<<<< + * righty = int(((cols-xx)*vy/vx)+yy) + * # cv2.line(orig,(cols-1,righty),(0,lefty),(0,255,0),2) */ - __pyx_t_10 = __Pyx_PyFloat_EqObjC(__pyx_v_itemhr, __pyx_float_0_1875, 0.1875, 0, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 304, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 304, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - if (__pyx_t_8) { - } else { - __pyx_t_2 = __pyx_t_8; - goto __pyx_L84_bool_binop_done; - } - __pyx_t_8 = (__pyx_v_rectangular != 0); - __pyx_t_2 = __pyx_t_8; - __pyx_L84_bool_binop_done:; - if (__pyx_t_2) { + __pyx_t_10 = PyNumber_Negative(__pyx_v_xx); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 306, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_4 = PyNumber_Multiply(__pyx_t_10, __pyx_v_vy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 306, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_v_vx); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 306, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyNumber_Add(__pyx_t_10, __pyx_v_yy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 306, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = __Pyx_PyNumber_Int(__pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 306, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF_SET(__pyx_v_lefty, __pyx_t_10); + __pyx_t_10 = 0; + + /* "detect.py":307 + * [vx, vy, xx, yy] = cv2.fitLine(c, cv2.DIST_L2, 0, 0.01, 0.01) + * lefty = int((-xx*vy/vx) + yy) + * righty = int(((cols-xx)*vy/vx)+yy) # <<<<<<<<<<<<<< + * # cv2.line(orig,(cols-1,righty),(0,lefty),(0,255,0),2) + * slope = (lefty - righty) / (1 - cols) + */ + __pyx_t_10 = PyNumber_Subtract(__pyx_v_cols, __pyx_v_xx); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 307, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_4 = PyNumber_Multiply(__pyx_t_10, __pyx_v_vy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 307, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_v_vx); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 307, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyNumber_Add(__pyx_t_10, __pyx_v_yy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 307, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = __Pyx_PyNumber_Int(__pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 307, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF_SET(__pyx_v_righty, __pyx_t_10); + __pyx_t_10 = 0; + + /* "detect.py":309 + * righty = int(((cols-xx)*vy/vx)+yy) + * # cv2.line(orig,(cols-1,righty),(0,lefty),(0,255,0),2) + * slope = (lefty - righty) / (1 - cols) # <<<<<<<<<<<<<< + * angle = math.atan(slope) + * xpos = x - math.cos(angle) * radius + */ + __pyx_t_10 = PyNumber_Subtract(__pyx_v_lefty, __pyx_v_righty); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 309, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_4 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_v_cols, 1, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 309, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_10, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 309, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF_SET(__pyx_v_slope, __pyx_t_3); + __pyx_t_3 = 0; + + /* "detect.py":310 + * # cv2.line(orig,(cols-1,righty),(0,lefty),(0,255,0),2) + * slope = (lefty - righty) / (1 - cols) + * angle = math.atan(slope) # <<<<<<<<<<<<<< + * xpos = x - math.cos(angle) * radius + * ypos = y - math.sin(angle) * radius + */ + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_math); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 310, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_atan); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 310, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_10, function); + } + } + __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_4, __pyx_v_slope) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_slope); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 310, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_XDECREF_SET(__pyx_v_angle, __pyx_t_3); + __pyx_t_3 = 0; - /* "detect.py":305 - * - * if itemhr == 0.1875 and rectangular: - * objtype = "Axle" # <<<<<<<<<<<<<< - * iteml = (radius * 2 / pixelsPerMetric + itemw) / 2 - * + /* "detect.py":311 + * slope = (lefty - righty) / (1 - cols) + * angle = math.atan(slope) + * xpos = x - math.cos(angle) * radius # <<<<<<<<<<<<<< + * ypos = y - math.sin(angle) * radius + * xpos2 = x + math.cos(angle) * radius */ - __Pyx_INCREF(__pyx_n_s_Axle); - __Pyx_DECREF_SET(__pyx_v_objtype, __pyx_n_s_Axle); + __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_math); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 311, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_cos); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 311, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_10)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_10); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + __pyx_t_3 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_10, __pyx_v_angle) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_angle); + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 311, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyNumber_Multiply(__pyx_t_3, __pyx_v_radius); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 311, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_Subtract(__pyx_v_x, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 311, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF_SET(__pyx_v_xpos, __pyx_t_3); + __pyx_t_3 = 0; - /* "detect.py":306 - * if itemhr == 0.1875 and rectangular: - * objtype = "Axle" - * iteml = (radius * 2 / pixelsPerMetric + itemw) / 2 # <<<<<<<<<<<<<< - * - * rows, cols = orig.shape[:2] + /* "detect.py":312 + * angle = math.atan(slope) + * xpos = x - math.cos(angle) * radius + * ypos = y - math.sin(angle) * radius # <<<<<<<<<<<<<< + * xpos2 = x + math.cos(angle) * radius + * ypos2 = y + math.sin(angle) * radius */ - __pyx_t_10 = PyNumber_Multiply(__pyx_v_radius, __pyx_int_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 306, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_10, __pyx_v_pixelsPerMetric); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 306, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = PyNumber_Add(__pyx_t_1, __pyx_v_itemw); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 306, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_10, __pyx_int_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 306, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_XDECREF_SET(__pyx_v_iteml, __pyx_t_1); - __pyx_t_1 = 0; + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_math); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 312, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_sin); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 312, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_10, function); + } + } + __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_4, __pyx_v_angle) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_angle); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 312, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = PyNumber_Multiply(__pyx_t_3, __pyx_v_radius); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 312, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_Subtract(__pyx_v_y, __pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 312, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_XDECREF_SET(__pyx_v_ypos, __pyx_t_3); + __pyx_t_3 = 0; - /* "detect.py":304 - * iteml = sizeStandoff(itemw) - * - * if itemhr == 0.1875 and rectangular: # <<<<<<<<<<<<<< - * objtype = "Axle" - * iteml = (radius * 2 / pixelsPerMetric + itemw) / 2 + /* "detect.py":313 + * xpos = x - math.cos(angle) * radius + * ypos = y - math.sin(angle) * radius + * xpos2 = x + math.cos(angle) * radius # <<<<<<<<<<<<<< + * ypos2 = y + math.sin(angle) * radius + * if xpos > xpos2: */ - } - } - __pyx_L74:; + __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_math); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 313, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_cos); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 313, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_10)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_10); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); } - __pyx_L61:; + } + __pyx_t_3 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_10, __pyx_v_angle) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_angle); + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 313, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyNumber_Multiply(__pyx_t_3, __pyx_v_radius); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 313, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_Add(__pyx_v_x, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 313, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF_SET(__pyx_v_xpos2, __pyx_t_3); + __pyx_t_3 = 0; - /* "detect.py":308 - * iteml = (radius * 2 / pixelsPerMetric + itemw) / 2 - * - * rows, cols = orig.shape[:2] # <<<<<<<<<<<<<< - * [vx, vy, xx, yy] = cv2.fitLine(c, cv2.DIST_L2, 0, 0.01, 0.01) - * lefty = int((-xx*vy/vx) + yy) + /* "detect.py":314 + * ypos = y - math.sin(angle) * radius + * xpos2 = x + math.cos(angle) * radius + * ypos2 = y + math.sin(angle) * radius # <<<<<<<<<<<<<< + * if xpos > xpos2: + * swap(xpos, xpos2) */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_orig, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = __Pyx_PyObject_GetSlice(__pyx_t_1, 0, 2, NULL, NULL, &__pyx_slice__6, 0, 1, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 308, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if ((likely(PyTuple_CheckExact(__pyx_t_10))) || (PyList_CheckExact(__pyx_t_10))) { - PyObject* sequence = __pyx_t_10; - Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); - if (unlikely(size != 2)) { - if (size > 2) __Pyx_RaiseTooManyValuesError(2); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 308, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); - } else { - __pyx_t_1 = PyList_GET_ITEM(sequence, 0); - __pyx_t_4 = PyList_GET_ITEM(sequence, 1); - } - __Pyx_INCREF(__pyx_t_1); + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_math); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 314, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_sin); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 314, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_4); - #else - __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 308, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #endif - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } else { - Py_ssize_t index = -1; - __pyx_t_3 = PyObject_GetIter(__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 308, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_14 = Py_TYPE(__pyx_t_3)->tp_iternext; - index = 0; __pyx_t_1 = __pyx_t_14(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L86_unpacking_failed; - __Pyx_GOTREF(__pyx_t_1); - index = 1; __pyx_t_4 = __pyx_t_14(__pyx_t_3); if (unlikely(!__pyx_t_4)) goto __pyx_L86_unpacking_failed; - __Pyx_GOTREF(__pyx_t_4); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_3), 2) < 0) __PYX_ERR(0, 308, __pyx_L1_error) - __pyx_t_14 = NULL; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - goto __pyx_L87_unpacking_done; - __pyx_L86_unpacking_failed:; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_14 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 308, __pyx_L1_error) - __pyx_L87_unpacking_done:; + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_10, function); } - __Pyx_XDECREF_SET(__pyx_v_rows, __pyx_t_1); - __pyx_t_1 = 0; - __Pyx_XDECREF_SET(__pyx_v_cols, __pyx_t_4); - __pyx_t_4 = 0; + } + __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_4, __pyx_v_angle) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_angle); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 314, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = PyNumber_Multiply(__pyx_t_3, __pyx_v_radius); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 314, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_Add(__pyx_v_y, __pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 314, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_XDECREF_SET(__pyx_v_ypos2, __pyx_t_3); + __pyx_t_3 = 0; - /* "detect.py":309 - * - * rows, cols = orig.shape[:2] - * [vx, vy, xx, yy] = cv2.fitLine(c, cv2.DIST_L2, 0, 0.01, 0.01) # <<<<<<<<<<<<<< - * lefty = int((-xx*vy/vx) + yy) - * righty = int(((cols-xx)*vy/vx)+yy) + /* "detect.py":315 + * xpos2 = x + math.cos(angle) * radius + * ypos2 = y + math.sin(angle) * radius + * if xpos > xpos2: # <<<<<<<<<<<<<< + * swap(xpos, xpos2) + * swap(ypos, ypos2) */ - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_cv2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 309, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_fitLine); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 309, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_cv2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 309, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_DIST_L2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 309, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_3 = PyObject_RichCompare(__pyx_v_xpos, __pyx_v_xpos2, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 315, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 315, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_2) { + + /* "detect.py":316 + * ypos2 = y + math.sin(angle) * radius + * if xpos > xpos2: + * swap(xpos, xpos2) # <<<<<<<<<<<<<< + * swap(ypos, ypos2) + * if rectangular: + */ + __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_swap); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 316, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); __pyx_t_4 = NULL; __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); + __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[6] = {__pyx_t_4, __pyx_v_c, __pyx_t_3, __pyx_int_0, __pyx_float_0_01, __pyx_float_0_01}; - __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 309, __pyx_L1_error) + if (PyFunction_Check(__pyx_t_10)) { + PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_xpos, __pyx_v_xpos2}; + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[6] = {__pyx_t_4, __pyx_v_c, __pyx_t_3, __pyx_int_0, __pyx_float_0_01, __pyx_float_0_01}; - __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 309, __pyx_L1_error) + if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { + PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_xpos, __pyx_v_xpos2}; + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_3); } else #endif { - __pyx_t_11 = PyTuple_New(5+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 309, __pyx_L1_error) + __pyx_t_11 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4); __pyx_t_4 = NULL; } - __Pyx_INCREF(__pyx_v_c); - __Pyx_GIVEREF(__pyx_v_c); - PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_9, __pyx_v_c); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_9, __pyx_t_3); - __Pyx_INCREF(__pyx_int_0); - __Pyx_GIVEREF(__pyx_int_0); - PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_9, __pyx_int_0); - __Pyx_INCREF(__pyx_float_0_01); - __Pyx_GIVEREF(__pyx_float_0_01); - PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_9, __pyx_float_0_01); - __Pyx_INCREF(__pyx_float_0_01); - __Pyx_GIVEREF(__pyx_float_0_01); - PyTuple_SET_ITEM(__pyx_t_11, 4+__pyx_t_9, __pyx_float_0_01); - __pyx_t_3 = 0; - __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 309, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if ((likely(PyTuple_CheckExact(__pyx_t_10))) || (PyList_CheckExact(__pyx_t_10))) { - PyObject* sequence = __pyx_t_10; - Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); - if (unlikely(size != 4)) { - if (size > 4) __Pyx_RaiseTooManyValuesError(4); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 309, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); - __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); - __pyx_t_4 = PyTuple_GET_ITEM(sequence, 3); - } else { - __pyx_t_1 = PyList_GET_ITEM(sequence, 0); - __pyx_t_11 = PyList_GET_ITEM(sequence, 1); - __pyx_t_3 = PyList_GET_ITEM(sequence, 2); - __pyx_t_4 = PyList_GET_ITEM(sequence, 3); - } - __Pyx_INCREF(__pyx_t_1); - __Pyx_INCREF(__pyx_t_11); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - #else - { - Py_ssize_t i; - PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_11,&__pyx_t_3,&__pyx_t_4}; - for (i=0; i < 4; i++) { - PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 309, __pyx_L1_error) - __Pyx_GOTREF(item); - *(temps[i]) = item; - } - } - #endif - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } else { - Py_ssize_t index = -1; - PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_11,&__pyx_t_3,&__pyx_t_4}; - __pyx_t_6 = PyObject_GetIter(__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 309, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_14 = Py_TYPE(__pyx_t_6)->tp_iternext; - for (index=0; index < 4; index++) { - PyObject* item = __pyx_t_14(__pyx_t_6); if (unlikely(!item)) goto __pyx_L88_unpacking_failed; - __Pyx_GOTREF(item); - *(temps[index]) = item; - } - if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_6), 4) < 0) __PYX_ERR(0, 309, __pyx_L1_error) - __pyx_t_14 = NULL; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - goto __pyx_L89_unpacking_done; - __pyx_L88_unpacking_failed:; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_14 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 309, __pyx_L1_error) - __pyx_L89_unpacking_done:; - } - __Pyx_XDECREF_SET(__pyx_v_vx, __pyx_t_1); - __pyx_t_1 = 0; - __Pyx_XDECREF_SET(__pyx_v_vy, __pyx_t_11); - __pyx_t_11 = 0; - __Pyx_XDECREF_SET(__pyx_v_xx, __pyx_t_3); - __pyx_t_3 = 0; - __Pyx_XDECREF_SET(__pyx_v_yy, __pyx_t_4); - __pyx_t_4 = 0; - - /* "detect.py":310 - * rows, cols = orig.shape[:2] - * [vx, vy, xx, yy] = cv2.fitLine(c, cv2.DIST_L2, 0, 0.01, 0.01) - * lefty = int((-xx*vy/vx) + yy) # <<<<<<<<<<<<<< - * righty = int(((cols-xx)*vy/vx)+yy) - * # cv2.line(orig,(cols-1,righty),(0,lefty),(0,255,0),2) - */ - __pyx_t_10 = PyNumber_Negative(__pyx_v_xx); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 310, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_4 = PyNumber_Multiply(__pyx_t_10, __pyx_v_vy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 310, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_v_vx); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 310, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyNumber_Add(__pyx_t_10, __pyx_v_yy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 310, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = __Pyx_PyNumber_Int(__pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 310, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_XDECREF_SET(__pyx_v_lefty, __pyx_t_10); - __pyx_t_10 = 0; - - /* "detect.py":311 - * [vx, vy, xx, yy] = cv2.fitLine(c, cv2.DIST_L2, 0, 0.01, 0.01) - * lefty = int((-xx*vy/vx) + yy) - * righty = int(((cols-xx)*vy/vx)+yy) # <<<<<<<<<<<<<< - * # cv2.line(orig,(cols-1,righty),(0,lefty),(0,255,0),2) - * slope = (lefty - righty) / (1 - cols) - */ - __pyx_t_10 = PyNumber_Subtract(__pyx_v_cols, __pyx_v_xx); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 311, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_4 = PyNumber_Multiply(__pyx_t_10, __pyx_v_vy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 311, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_v_vx); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 311, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyNumber_Add(__pyx_t_10, __pyx_v_yy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 311, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = __Pyx_PyNumber_Int(__pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 311, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_XDECREF_SET(__pyx_v_righty, __pyx_t_10); - __pyx_t_10 = 0; - - /* "detect.py":313 - * righty = int(((cols-xx)*vy/vx)+yy) - * # cv2.line(orig,(cols-1,righty),(0,lefty),(0,255,0),2) - * slope = (lefty - righty) / (1 - cols) # <<<<<<<<<<<<<< - * angle = math.atan(slope) - * xpos = x - math.cos(angle) * radius - */ - __pyx_t_10 = PyNumber_Subtract(__pyx_v_lefty, __pyx_v_righty); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 313, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_4 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_v_cols, 1, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 313, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_10, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 313, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_XDECREF_SET(__pyx_v_slope, __pyx_t_3); - __pyx_t_3 = 0; - - /* "detect.py":314 - * # cv2.line(orig,(cols-1,righty),(0,lefty),(0,255,0),2) - * slope = (lefty - righty) / (1 - cols) - * angle = math.atan(slope) # <<<<<<<<<<<<<< - * xpos = x - math.cos(angle) * radius - * ypos = y - math.sin(angle) * radius - */ - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_math); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 314, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_atan); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 314, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_10, function); - } - } - __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_4, __pyx_v_slope) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_slope); - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 314, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_XDECREF_SET(__pyx_v_angle, __pyx_t_3); - __pyx_t_3 = 0; - - /* "detect.py":315 - * slope = (lefty - righty) / (1 - cols) - * angle = math.atan(slope) - * xpos = x - math.cos(angle) * radius # <<<<<<<<<<<<<< - * ypos = y - math.sin(angle) * radius - * xpos2 = x + math.cos(angle) * radius - */ - __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_math); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 315, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_cos); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 315, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_10)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_10); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - } - } - __pyx_t_3 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_10, __pyx_v_angle) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_angle); - __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 315, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyNumber_Multiply(__pyx_t_3, __pyx_v_radius); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 315, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_xpos); + __Pyx_GIVEREF(__pyx_v_xpos); + PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_9, __pyx_v_xpos); + __Pyx_INCREF(__pyx_v_xpos2); + __Pyx_GIVEREF(__pyx_v_xpos2); + PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_9, __pyx_v_xpos2); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyNumber_Subtract(__pyx_v_x, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 315, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_XDECREF_SET(__pyx_v_xpos, __pyx_t_3); - __pyx_t_3 = 0; - /* "detect.py":316 - * angle = math.atan(slope) - * xpos = x - math.cos(angle) * radius - * ypos = y - math.sin(angle) * radius # <<<<<<<<<<<<<< - * xpos2 = x + math.cos(angle) * radius - * ypos2 = y + math.sin(angle) * radius + /* "detect.py":317 + * if xpos > xpos2: + * swap(xpos, xpos2) + * swap(ypos, ypos2) # <<<<<<<<<<<<<< + * if rectangular: + * cv2.line(orig, (int(xpos), int(ypos)), */ - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_math); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 316, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_sin); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 316, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_swap); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 317, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = NULL; + __pyx_t_11 = NULL; + __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10); - if (likely(__pyx_t_4)) { + __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10); + if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); - __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); + __pyx_t_9 = 1; } } - __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_4, __pyx_v_angle) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_angle); - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_10)) { + PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_v_ypos, __pyx_v_ypos2}; + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 317, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_GOTREF(__pyx_t_3); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { + PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_v_ypos, __pyx_v_ypos2}; + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 317, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_GOTREF(__pyx_t_3); + } else + #endif + { + __pyx_t_4 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 317, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + if (__pyx_t_11) { + __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_11); __pyx_t_11 = NULL; + } + __Pyx_INCREF(__pyx_v_ypos); + __Pyx_GIVEREF(__pyx_v_ypos); + PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_9, __pyx_v_ypos); + __Pyx_INCREF(__pyx_v_ypos2); + __Pyx_GIVEREF(__pyx_v_ypos2); + PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_9, __pyx_v_ypos2); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 317, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = PyNumber_Multiply(__pyx_t_3, __pyx_v_radius); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 316, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyNumber_Subtract(__pyx_v_y, __pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_XDECREF_SET(__pyx_v_ypos, __pyx_t_3); - __pyx_t_3 = 0; - /* "detect.py":317 - * xpos = x - math.cos(angle) * radius - * ypos = y - math.sin(angle) * radius - * xpos2 = x + math.cos(angle) * radius # <<<<<<<<<<<<<< - * ypos2 = y + math.sin(angle) * radius - * if xpos > xpos2: + /* "detect.py":315 + * xpos2 = x + math.cos(angle) * radius + * ypos2 = y + math.sin(angle) * radius + * if xpos > xpos2: # <<<<<<<<<<<<<< + * swap(xpos, xpos2) + * swap(ypos, ypos2) */ - __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_math); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 317, __pyx_L1_error) + } + + /* "detect.py":318 + * swap(xpos, xpos2) + * swap(ypos, ypos2) + * if rectangular: # <<<<<<<<<<<<<< + * cv2.line(orig, (int(xpos), int(ypos)), + * (int(xpos2), int(ypos2)), (255, 127, 0), 2) + */ + __pyx_t_2 = (__pyx_v_rectangular != 0); + if (__pyx_t_2) { + + /* "detect.py":319 + * swap(ypos, ypos2) + * if rectangular: + * cv2.line(orig, (int(xpos), int(ypos)), # <<<<<<<<<<<<<< + * (int(xpos2), int(ypos2)), (255, 127, 0), 2) + * # print(str(iteml)) + */ + __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_cv2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 319, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_cos); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 317, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_line); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 319, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = __Pyx_PyNumber_Int(__pyx_v_xpos); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 319, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_11 = __Pyx_PyNumber_Int(__pyx_v_ypos); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 319, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 319, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_11); + __pyx_t_10 = 0; + __pyx_t_11 = 0; + + /* "detect.py":320 + * if rectangular: + * cv2.line(orig, (int(xpos), int(ypos)), + * (int(xpos2), int(ypos2)), (255, 127, 0), 2) # <<<<<<<<<<<<<< + * # print(str(iteml)) + * # draw the object sizes on the image + */ + __pyx_t_11 = __Pyx_PyNumber_Int(__pyx_v_xpos2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 320, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_10 = __Pyx_PyNumber_Int(__pyx_v_ypos2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 320, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 320, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_10); + __pyx_t_11 = 0; + __pyx_t_10 = 0; __pyx_t_10 = NULL; + __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_10)) { @@ -9157,1201 +9378,927 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_9 = 1; } } - __pyx_t_3 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_10, __pyx_v_angle) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_angle); - __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 317, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[6] = {__pyx_t_10, __pyx_v_orig, __pyx_t_1, __pyx_t_6, __pyx_tuple__7, __pyx_int_2}; + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 319, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[6] = {__pyx_t_10, __pyx_v_orig, __pyx_t_1, __pyx_t_6, __pyx_tuple__7, __pyx_int_2}; + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 319, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } else + #endif + { + __pyx_t_11 = PyTuple_New(5+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 319, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + if (__pyx_t_10) { + __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL; + } + __Pyx_INCREF(__pyx_v_orig); + __Pyx_GIVEREF(__pyx_v_orig); + PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_9, __pyx_v_orig); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_9, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_9, __pyx_t_6); + __Pyx_INCREF(__pyx_tuple__7); + __Pyx_GIVEREF(__pyx_tuple__7); + PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_9, __pyx_tuple__7); + __Pyx_INCREF(__pyx_int_2); + __Pyx_GIVEREF(__pyx_int_2); + PyTuple_SET_ITEM(__pyx_t_11, 4+__pyx_t_9, __pyx_int_2); + __pyx_t_1 = 0; + __pyx_t_6 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 319, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyNumber_Multiply(__pyx_t_3, __pyx_v_radius); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 317, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyNumber_Add(__pyx_v_x, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 317, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_XDECREF_SET(__pyx_v_xpos2, __pyx_t_3); - __pyx_t_3 = 0; /* "detect.py":318 - * ypos = y - math.sin(angle) * radius - * xpos2 = x + math.cos(angle) * radius - * ypos2 = y + math.sin(angle) * radius # <<<<<<<<<<<<<< - * if xpos > xpos2: - * swap(xpos, xpos2) + * swap(xpos, xpos2) + * swap(ypos, ypos2) + * if rectangular: # <<<<<<<<<<<<<< + * cv2.line(orig, (int(xpos), int(ypos)), + * (int(xpos2), int(ypos2)), (255, 127, 0), 2) + */ + } + + /* "detect.py":326 + * # (int(trbrX + 20), int(trbrY)), cv2.FONT_HERSHEY_SIMPLEX, + * # 0.65, (255, 255, 255), 2) + * if circular: # <<<<<<<<<<<<<< + * cv2.putText(orig, str(objtype), + * (int(x - 25), int(y + radius + 20) + */ + __pyx_t_2 = (__pyx_v_circular != 0); + if (__pyx_t_2) { + + /* "detect.py":327 + * # 0.65, (255, 255, 255), 2) + * if circular: + * cv2.putText(orig, str(objtype), # <<<<<<<<<<<<<< + * (int(x - 25), int(y + radius + 20) + * ), cv2.FONT_HERSHEY_SIMPLEX, */ - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_math); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 318, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_cv2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 327, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_sin); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 318, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_putText); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 327, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_10, function); - } - } - __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_4, __pyx_v_angle) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_angle); - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 318, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = PyNumber_Multiply(__pyx_t_3, __pyx_v_radius); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 318, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_objtype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 327, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + + /* "detect.py":328 + * if circular: + * cv2.putText(orig, str(objtype), + * (int(x - 25), int(y + radius + 20) # <<<<<<<<<<<<<< + * ), cv2.FONT_HERSHEY_SIMPLEX, + * 0.6, (50, 50, 220), 2) + */ + __pyx_t_6 = __Pyx_PyInt_SubtractObjC(__pyx_v_x, __pyx_int_25, 25, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 328, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 328, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = PyNumber_Add(__pyx_v_y, __pyx_v_radius); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 328, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_10 = __Pyx_PyInt_AddObjC(__pyx_t_6, __pyx_int_20, 20, 0, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 328, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyNumber_Add(__pyx_v_y, __pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 318, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyNumber_Int(__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 328, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_XDECREF_SET(__pyx_v_ypos2, __pyx_t_3); - __pyx_t_3 = 0; - - /* "detect.py":319 - * xpos2 = x + math.cos(angle) * radius - * ypos2 = y + math.sin(angle) * radius - * if xpos > xpos2: # <<<<<<<<<<<<<< - * swap(xpos, xpos2) - * swap(ypos, ypos2) - */ - __pyx_t_3 = PyObject_RichCompare(__pyx_v_xpos, __pyx_v_xpos2, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 319, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 319, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_2) { + __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 328, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_6); + __pyx_t_1 = 0; + __pyx_t_6 = 0; - /* "detect.py":320 - * ypos2 = y + math.sin(angle) * radius - * if xpos > xpos2: - * swap(xpos, xpos2) # <<<<<<<<<<<<<< - * swap(ypos, ypos2) - * if rectangular: + /* "detect.py":329 + * cv2.putText(orig, str(objtype), + * (int(x - 25), int(y + radius + 20) + * ), cv2.FONT_HERSHEY_SIMPLEX, # <<<<<<<<<<<<<< + * 0.6, (50, 50, 220), 2) + * else: */ - __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_swap); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 320, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_4 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_10, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_10)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_xpos, __pyx_v_xpos2}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 320, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_3); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_xpos, __pyx_v_xpos2}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 320, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_3); - } else - #endif - { - __pyx_t_11 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 320, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - if (__pyx_t_4) { - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4); __pyx_t_4 = NULL; - } - __Pyx_INCREF(__pyx_v_xpos); - __Pyx_GIVEREF(__pyx_v_xpos); - PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_9, __pyx_v_xpos); - __Pyx_INCREF(__pyx_v_xpos2); - __Pyx_GIVEREF(__pyx_v_xpos2); - PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_9, __pyx_v_xpos2); - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 320, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - } - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_cv2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 329, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_FONT_HERSHEY_SIMPLEX); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 329, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "detect.py":321 - * if xpos > xpos2: - * swap(xpos, xpos2) - * swap(ypos, ypos2) # <<<<<<<<<<<<<< - * if rectangular: - * cv2.line(orig, (int(xpos), int(ypos)), + /* "detect.py":330 + * (int(x - 25), int(y + radius + 20) + * ), cv2.FONT_HERSHEY_SIMPLEX, + * 0.6, (50, 50, 220), 2) # <<<<<<<<<<<<<< + * else: + * cv2.putText(orig, str(objtype), */ - __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_swap); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 321, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_11 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { - __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10); - if (likely(__pyx_t_11)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); - __Pyx_INCREF(__pyx_t_11); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_10, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_10)) { - PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_v_ypos, __pyx_v_ypos2}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 321, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_GOTREF(__pyx_t_3); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { - PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_v_ypos, __pyx_v_ypos2}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 321, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_GOTREF(__pyx_t_3); - } else - #endif - { - __pyx_t_4 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 321, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - if (__pyx_t_11) { - __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_11); __pyx_t_11 = NULL; - } - __Pyx_INCREF(__pyx_v_ypos); - __Pyx_GIVEREF(__pyx_v_ypos); - PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_9, __pyx_v_ypos); - __Pyx_INCREF(__pyx_v_ypos2); - __Pyx_GIVEREF(__pyx_v_ypos2); - PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_9, __pyx_v_ypos2); - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 321, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = NULL; + __pyx_t_9 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_11); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_11, function); + __pyx_t_9 = 1; } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_11)) { + PyObject *__pyx_temp[8] = {__pyx_t_6, __pyx_v_orig, __pyx_t_4, __pyx_t_10, __pyx_t_1, __pyx_float_0_6, __pyx_tuple__8, __pyx_int_2}; + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_9, 7+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 327, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { + PyObject *__pyx_temp[8] = {__pyx_t_6, __pyx_v_orig, __pyx_t_4, __pyx_t_10, __pyx_t_1, __pyx_float_0_6, __pyx_tuple__8, __pyx_int_2}; + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_9, 7+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 327, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + #endif + { + __pyx_t_15 = PyTuple_New(7+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 327, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_15); + if (__pyx_t_6) { + __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_6); __pyx_t_6 = NULL; + } + __Pyx_INCREF(__pyx_v_orig); + __Pyx_GIVEREF(__pyx_v_orig); + PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_9, __pyx_v_orig); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_9, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_15, 2+__pyx_t_9, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_15, 3+__pyx_t_9, __pyx_t_1); + __Pyx_INCREF(__pyx_float_0_6); + __Pyx_GIVEREF(__pyx_float_0_6); + PyTuple_SET_ITEM(__pyx_t_15, 4+__pyx_t_9, __pyx_float_0_6); + __Pyx_INCREF(__pyx_tuple__8); + __Pyx_GIVEREF(__pyx_tuple__8); + PyTuple_SET_ITEM(__pyx_t_15, 5+__pyx_t_9, __pyx_tuple__8); + __Pyx_INCREF(__pyx_int_2); + __Pyx_GIVEREF(__pyx_int_2); + PyTuple_SET_ITEM(__pyx_t_15, 6+__pyx_t_9, __pyx_int_2); + __pyx_t_4 = 0; + __pyx_t_10 = 0; + __pyx_t_1 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_15, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 327, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + } + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "detect.py":319 - * xpos2 = x + math.cos(angle) * radius - * ypos2 = y + math.sin(angle) * radius - * if xpos > xpos2: # <<<<<<<<<<<<<< - * swap(xpos, xpos2) - * swap(ypos, ypos2) + /* "detect.py":326 + * # (int(trbrX + 20), int(trbrY)), cv2.FONT_HERSHEY_SIMPLEX, + * # 0.65, (255, 255, 255), 2) + * if circular: # <<<<<<<<<<<<<< + * cv2.putText(orig, str(objtype), + * (int(x - 25), int(y + radius + 20) */ - } + goto __pyx_L89; + } - /* "detect.py":322 - * swap(xpos, xpos2) - * swap(ypos, ypos2) - * if rectangular: # <<<<<<<<<<<<<< - * cv2.line(orig, (int(xpos), int(ypos)), - * (int(xpos2), int(ypos2)), (255, 127, 0), 2) + /* "detect.py":332 + * 0.6, (50, 50, 220), 2) + * else: + * cv2.putText(orig, str(objtype), # <<<<<<<<<<<<<< + * (int(xpos2 + 10), int(ypos2 + 20) + * ), cv2.FONT_HERSHEY_SIMPLEX, */ - __pyx_t_2 = (__pyx_v_rectangular != 0); - if (__pyx_t_2) { + /*else*/ { + __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_cv2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 332, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_putText); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 332, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_objtype); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 332, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); - /* "detect.py":323 - * swap(ypos, ypos2) - * if rectangular: - * cv2.line(orig, (int(xpos), int(ypos)), # <<<<<<<<<<<<<< - * (int(xpos2), int(ypos2)), (255, 127, 0), 2) - * # print(str(iteml)) + /* "detect.py":333 + * else: + * cv2.putText(orig, str(objtype), + * (int(xpos2 + 10), int(ypos2 + 20) # <<<<<<<<<<<<<< + * ), cv2.FONT_HERSHEY_SIMPLEX, + * 0.6, (50, 50, 220), 2) */ - __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_cv2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 323, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_line); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 323, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = __Pyx_PyNumber_Int(__pyx_v_xpos); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 323, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_11 = __Pyx_PyNumber_Int(__pyx_v_ypos); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 323, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 323, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_10); - __Pyx_GIVEREF(__pyx_t_11); - PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_11); - __pyx_t_10 = 0; - __pyx_t_11 = 0; + __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_v_xpos2, __pyx_int_10, 10, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_10 = __Pyx_PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 333, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_v_ypos2, __pyx_int_20, 20, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 333, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4); + __pyx_t_10 = 0; + __pyx_t_4 = 0; - /* "detect.py":324 - * if rectangular: - * cv2.line(orig, (int(xpos), int(ypos)), - * (int(xpos2), int(ypos2)), (255, 127, 0), 2) # <<<<<<<<<<<<<< - * # print(str(iteml)) - * # draw the object sizes on the image + /* "detect.py":334 + * cv2.putText(orig, str(objtype), + * (int(xpos2 + 10), int(ypos2 + 20) + * ), cv2.FONT_HERSHEY_SIMPLEX, # <<<<<<<<<<<<<< + * 0.6, (50, 50, 220), 2) + * output = "" */ - __pyx_t_11 = __Pyx_PyNumber_Int(__pyx_v_xpos2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 324, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_10 = __Pyx_PyNumber_Int(__pyx_v_ypos2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 324, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 324, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_cv2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 334, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_FONT_HERSHEY_SIMPLEX); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 334, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "detect.py":335 + * (int(xpos2 + 10), int(ypos2 + 20) + * ), cv2.FONT_HERSHEY_SIMPLEX, + * 0.6, (50, 50, 220), 2) # <<<<<<<<<<<<<< + * output = "" + * objname = objtype; + */ + __pyx_t_4 = NULL; + __pyx_t_9 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_15); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_15, function); + __pyx_t_9 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_15)) { + PyObject *__pyx_temp[8] = {__pyx_t_4, __pyx_v_orig, __pyx_t_11, __pyx_t_1, __pyx_t_10, __pyx_float_0_6, __pyx_tuple__8, __pyx_int_2}; + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_15, __pyx_temp+1-__pyx_t_9, 7+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 332, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) { + PyObject *__pyx_temp[8] = {__pyx_t_4, __pyx_v_orig, __pyx_t_11, __pyx_t_1, __pyx_t_10, __pyx_float_0_6, __pyx_tuple__8, __pyx_int_2}; + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_15, __pyx_temp+1-__pyx_t_9, 7+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 332, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } else + #endif + { + __pyx_t_6 = PyTuple_New(7+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 332, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); + if (__pyx_t_4) { + __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; + } + __Pyx_INCREF(__pyx_v_orig); + __Pyx_GIVEREF(__pyx_v_orig); + PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_9, __pyx_v_orig); __Pyx_GIVEREF(__pyx_t_11); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_9, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_9, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_9, __pyx_t_10); + __Pyx_INCREF(__pyx_float_0_6); + __Pyx_GIVEREF(__pyx_float_0_6); + PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_9, __pyx_float_0_6); + __Pyx_INCREF(__pyx_tuple__8); + __Pyx_GIVEREF(__pyx_tuple__8); + PyTuple_SET_ITEM(__pyx_t_6, 5+__pyx_t_9, __pyx_tuple__8); + __Pyx_INCREF(__pyx_int_2); + __Pyx_GIVEREF(__pyx_int_2); + PyTuple_SET_ITEM(__pyx_t_6, 6+__pyx_t_9, __pyx_int_2); __pyx_t_11 = 0; + __pyx_t_1 = 0; __pyx_t_10 = 0; - __pyx_t_10 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_10)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_10); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[6] = {__pyx_t_10, __pyx_v_orig, __pyx_t_1, __pyx_t_6, __pyx_tuple__7, __pyx_int_2}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 323, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[6] = {__pyx_t_10, __pyx_v_orig, __pyx_t_1, __pyx_t_6, __pyx_tuple__7, __pyx_int_2}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 323, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - { - __pyx_t_11 = PyTuple_New(5+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 323, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - if (__pyx_t_10) { - __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL; - } - __Pyx_INCREF(__pyx_v_orig); - __Pyx_GIVEREF(__pyx_v_orig); - PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_9, __pyx_v_orig); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_9, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_9, __pyx_t_6); - __Pyx_INCREF(__pyx_tuple__7); - __Pyx_GIVEREF(__pyx_tuple__7); - PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_9, __pyx_tuple__7); - __Pyx_INCREF(__pyx_int_2); - __Pyx_GIVEREF(__pyx_int_2); - PyTuple_SET_ITEM(__pyx_t_11, 4+__pyx_t_9, __pyx_int_2); - __pyx_t_1 = 0; - __pyx_t_6 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 323, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "detect.py":322 - * swap(xpos, xpos2) - * swap(ypos, ypos2) - * if rectangular: # <<<<<<<<<<<<<< - * cv2.line(orig, (int(xpos), int(ypos)), - * (int(xpos2), int(ypos2)), (255, 127, 0), 2) - */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 332, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + __pyx_L89:; - /* "detect.py":327 - * # print(str(iteml)) - * # draw the object sizes on the image - * if show or True: # <<<<<<<<<<<<<< - * # cv2.putText(orig, "{:.5f}in".format(itemhr), - * # (int(trbrX + 20), int(trbrY)), cv2.FONT_HERSHEY_SIMPLEX, + /* "detect.py":336 + * ), cv2.FONT_HERSHEY_SIMPLEX, + * 0.6, (50, 50, 220), 2) + * output = "" # <<<<<<<<<<<<<< + * objname = objtype; + * if objtype == "Unknown": */ - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_show); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 327, __pyx_L1_error) - if (!__pyx_t_8) { - } else { - __pyx_t_2 = __pyx_t_8; - goto __pyx_L93_bool_binop_done; - } - __pyx_t_2 = 1; - __pyx_L93_bool_binop_done:; - if (__pyx_t_2) { + __Pyx_INCREF(__pyx_kp_s__3); + __Pyx_XDECREF_SET(__pyx_v_output, __pyx_kp_s__3); - /* "detect.py":331 - * # (int(trbrX + 20), int(trbrY)), cv2.FONT_HERSHEY_SIMPLEX, - * # 0.65, (255, 255, 255), 2) - * if circular: # <<<<<<<<<<<<<< - * cv2.putText(orig, str(objtype), - * (int(x - 25), int(y + radius + 20) + /* "detect.py":337 + * 0.6, (50, 50, 220), 2) + * output = "" + * objname = objtype; # <<<<<<<<<<<<<< + * if objtype == "Unknown": + * output = "{:.2f}in".format(itemw) + " x {:.2f}in".format(itemh) */ - __pyx_t_2 = (__pyx_v_circular != 0); - if (__pyx_t_2) { + __Pyx_INCREF(__pyx_v_objtype); + __Pyx_DECREF_SET(__pyx_v_objname, __pyx_v_objtype); - /* "detect.py":332 - * # 0.65, (255, 255, 255), 2) - * if circular: - * cv2.putText(orig, str(objtype), # <<<<<<<<<<<<<< - * (int(x - 25), int(y + radius + 20) - * ), cv2.FONT_HERSHEY_SIMPLEX, + /* "detect.py":338 + * output = "" + * objname = objtype; + * if objtype == "Unknown": # <<<<<<<<<<<<<< + * output = "{:.2f}in".format(itemw) + " x {:.2f}in".format(itemh) + * if objtype == "Screw" or objtype == "Standoff": */ - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_cv2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 332, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_putText); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 332, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_objtype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 332, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); + __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_objtype, __pyx_n_s_Unknown, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 338, __pyx_L1_error) + if (__pyx_t_2) { - /* "detect.py":333 - * if circular: - * cv2.putText(orig, str(objtype), - * (int(x - 25), int(y + radius + 20) # <<<<<<<<<<<<<< - * ), cv2.FONT_HERSHEY_SIMPLEX, - * 0.6, (50, 50, 220), 2) + /* "detect.py":339 + * objname = objtype; + * if objtype == "Unknown": + * output = "{:.2f}in".format(itemw) + " x {:.2f}in".format(itemh) # <<<<<<<<<<<<<< + * if objtype == "Screw" or objtype == "Standoff": + * output = str(iteml) + "in" */ - __pyx_t_6 = __Pyx_PyInt_SubtractObjC(__pyx_v_x, __pyx_int_25, 25, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 333, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyNumber_Add(__pyx_v_y, __pyx_v_radius); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 333, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_10 = __Pyx_PyInt_AddObjC(__pyx_t_6, __pyx_int_20, 20, 0, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 333, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyNumber_Int(__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 333, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 333, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_6); - __pyx_t_1 = 0; - __pyx_t_6 = 0; - - /* "detect.py":334 - * cv2.putText(orig, str(objtype), - * (int(x - 25), int(y + radius + 20) - * ), cv2.FONT_HERSHEY_SIMPLEX, # <<<<<<<<<<<<<< - * 0.6, (50, 50, 220), 2) - * else: - */ - __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_cv2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 334, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_FONT_HERSHEY_SIMPLEX); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 334, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - - /* "detect.py":335 - * (int(x - 25), int(y + radius + 20) - * ), cv2.FONT_HERSHEY_SIMPLEX, - * 0.6, (50, 50, 220), 2) # <<<<<<<<<<<<<< - * else: - * cv2.putText(orig, str(objtype), - */ - __pyx_t_6 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_11); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_11, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_11)) { - PyObject *__pyx_temp[8] = {__pyx_t_6, __pyx_v_orig, __pyx_t_4, __pyx_t_10, __pyx_t_1, __pyx_float_0_6, __pyx_tuple__8, __pyx_int_2}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_9, 7+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 332, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { - PyObject *__pyx_temp[8] = {__pyx_t_6, __pyx_v_orig, __pyx_t_4, __pyx_t_10, __pyx_t_1, __pyx_float_0_6, __pyx_tuple__8, __pyx_int_2}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_9, 7+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 332, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - #endif - { - __pyx_t_15 = PyTuple_New(7+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 332, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_15); - if (__pyx_t_6) { - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_6); __pyx_t_6 = NULL; - } - __Pyx_INCREF(__pyx_v_orig); - __Pyx_GIVEREF(__pyx_v_orig); - PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_9, __pyx_v_orig); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_9, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_15, 2+__pyx_t_9, __pyx_t_10); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_15, 3+__pyx_t_9, __pyx_t_1); - __Pyx_INCREF(__pyx_float_0_6); - __Pyx_GIVEREF(__pyx_float_0_6); - PyTuple_SET_ITEM(__pyx_t_15, 4+__pyx_t_9, __pyx_float_0_6); - __Pyx_INCREF(__pyx_tuple__8); - __Pyx_GIVEREF(__pyx_tuple__8); - PyTuple_SET_ITEM(__pyx_t_15, 5+__pyx_t_9, __pyx_tuple__8); - __Pyx_INCREF(__pyx_int_2); - __Pyx_GIVEREF(__pyx_int_2); - PyTuple_SET_ITEM(__pyx_t_15, 6+__pyx_t_9, __pyx_int_2); - __pyx_t_4 = 0; - __pyx_t_10 = 0; - __pyx_t_1 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_15, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 332, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - } - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_2f_in, __pyx_n_s_format); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 339, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_6 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_15))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_15); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_15, function); + } + } + __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_15, __pyx_t_6, __pyx_v_itemw) : __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_v_itemw); + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 339, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_x_2f_in, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 339, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_10 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { + __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6); + if (likely(__pyx_t_10)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); + __Pyx_INCREF(__pyx_t_10); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_6, function); + } + } + __pyx_t_15 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_10, __pyx_v_itemh) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_itemh); + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 339, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = PyNumber_Add(__pyx_t_3, __pyx_t_15); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 339, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_DECREF_SET(__pyx_v_output, __pyx_t_6); + __pyx_t_6 = 0; - /* "detect.py":331 - * # (int(trbrX + 20), int(trbrY)), cv2.FONT_HERSHEY_SIMPLEX, - * # 0.65, (255, 255, 255), 2) - * if circular: # <<<<<<<<<<<<<< - * cv2.putText(orig, str(objtype), - * (int(x - 25), int(y + radius + 20) + /* "detect.py":338 + * output = "" + * objname = objtype; + * if objtype == "Unknown": # <<<<<<<<<<<<<< + * output = "{:.2f}in".format(itemw) + " x {:.2f}in".format(itemh) + * if objtype == "Screw" or objtype == "Standoff": */ - goto __pyx_L95; - } + } - /* "detect.py":337 - * 0.6, (50, 50, 220), 2) - * else: - * cv2.putText(orig, str(objtype), # <<<<<<<<<<<<<< - * (int(xpos2 + 10), int(ypos2 + 20) - * ), cv2.FONT_HERSHEY_SIMPLEX, + /* "detect.py":340 + * if objtype == "Unknown": + * output = "{:.2f}in".format(itemw) + " x {:.2f}in".format(itemh) + * if objtype == "Screw" or objtype == "Standoff": # <<<<<<<<<<<<<< + * output = str(iteml) + "in" + * objname += str(iteml) */ - /*else*/ { - __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_cv2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 337, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_putText); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 337, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_objtype); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 337, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); + __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_objtype, __pyx_n_s_Screw, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 340, __pyx_L1_error) + if (!__pyx_t_8) { + } else { + __pyx_t_2 = __pyx_t_8; + goto __pyx_L92_bool_binop_done; + } + __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_objtype, __pyx_n_s_Standoff, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 340, __pyx_L1_error) + __pyx_t_2 = __pyx_t_8; + __pyx_L92_bool_binop_done:; + if (__pyx_t_2) { - /* "detect.py":338 - * else: - * cv2.putText(orig, str(objtype), - * (int(xpos2 + 10), int(ypos2 + 20) # <<<<<<<<<<<<<< - * ), cv2.FONT_HERSHEY_SIMPLEX, - * 0.6, (50, 50, 220), 2) + /* "detect.py":341 + * output = "{:.2f}in".format(itemw) + " x {:.2f}in".format(itemh) + * if objtype == "Screw" or objtype == "Standoff": + * output = str(iteml) + "in" # <<<<<<<<<<<<<< + * objname += str(iteml) + * if objtype == "Axle": */ - __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_v_xpos2, __pyx_int_10, 10, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 338, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = __Pyx_PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 338, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_v_ypos2, __pyx_int_20, 20, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 338, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 338, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 338, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_10); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4); - __pyx_t_10 = 0; - __pyx_t_4 = 0; + if (unlikely(!__pyx_v_iteml)) { __Pyx_RaiseUnboundLocalError("iteml"); __PYX_ERR(0, 341, __pyx_L1_error) } + __pyx_t_6 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_iteml); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 341, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_15 = PyNumber_Add(__pyx_t_6, __pyx_n_s_in); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 341, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF_SET(__pyx_v_output, __pyx_t_15); + __pyx_t_15 = 0; + + /* "detect.py":342 + * if objtype == "Screw" or objtype == "Standoff": + * output = str(iteml) + "in" + * objname += str(iteml) # <<<<<<<<<<<<<< + * if objtype == "Axle": + * output = "{:.2f}in".format(iteml) + */ + if (unlikely(!__pyx_v_iteml)) { __Pyx_RaiseUnboundLocalError("iteml"); __PYX_ERR(0, 342, __pyx_L1_error) } + __pyx_t_15 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_iteml); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 342, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_v_objname, __pyx_t_15); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 342, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_DECREF_SET(__pyx_v_objname, __pyx_t_6); + __pyx_t_6 = 0; - /* "detect.py":339 - * cv2.putText(orig, str(objtype), - * (int(xpos2 + 10), int(ypos2 + 20) - * ), cv2.FONT_HERSHEY_SIMPLEX, # <<<<<<<<<<<<<< - * 0.6, (50, 50, 220), 2) - * output = "" + /* "detect.py":340 + * if objtype == "Unknown": + * output = "{:.2f}in".format(itemw) + " x {:.2f}in".format(itemh) + * if objtype == "Screw" or objtype == "Standoff": # <<<<<<<<<<<<<< + * output = str(iteml) + "in" + * objname += str(iteml) */ - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_cv2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 339, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_FONT_HERSHEY_SIMPLEX); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 339, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } - /* "detect.py":340 - * (int(xpos2 + 10), int(ypos2 + 20) - * ), cv2.FONT_HERSHEY_SIMPLEX, - * 0.6, (50, 50, 220), 2) # <<<<<<<<<<<<<< - * output = "" - * objname = objtype; + /* "detect.py":343 + * output = str(iteml) + "in" + * objname += str(iteml) + * if objtype == "Axle": # <<<<<<<<<<<<<< + * output = "{:.2f}in".format(iteml) + * objname += str(itemwr) */ - __pyx_t_4 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_15); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_15, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_15)) { - PyObject *__pyx_temp[8] = {__pyx_t_4, __pyx_v_orig, __pyx_t_11, __pyx_t_1, __pyx_t_10, __pyx_float_0_6, __pyx_tuple__8, __pyx_int_2}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_15, __pyx_temp+1-__pyx_t_9, 7+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 337, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) { - PyObject *__pyx_temp[8] = {__pyx_t_4, __pyx_v_orig, __pyx_t_11, __pyx_t_1, __pyx_t_10, __pyx_float_0_6, __pyx_tuple__8, __pyx_int_2}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_15, __pyx_temp+1-__pyx_t_9, 7+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 337, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } else - #endif - { - __pyx_t_6 = PyTuple_New(7+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 337, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - if (__pyx_t_4) { - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; - } - __Pyx_INCREF(__pyx_v_orig); - __Pyx_GIVEREF(__pyx_v_orig); - PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_9, __pyx_v_orig); - __Pyx_GIVEREF(__pyx_t_11); - PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_9, __pyx_t_11); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_9, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_9, __pyx_t_10); - __Pyx_INCREF(__pyx_float_0_6); - __Pyx_GIVEREF(__pyx_float_0_6); - PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_9, __pyx_float_0_6); - __Pyx_INCREF(__pyx_tuple__8); - __Pyx_GIVEREF(__pyx_tuple__8); - PyTuple_SET_ITEM(__pyx_t_6, 5+__pyx_t_9, __pyx_tuple__8); - __Pyx_INCREF(__pyx_int_2); - __Pyx_GIVEREF(__pyx_int_2); - PyTuple_SET_ITEM(__pyx_t_6, 6+__pyx_t_9, __pyx_int_2); - __pyx_t_11 = 0; - __pyx_t_1 = 0; - __pyx_t_10 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 337, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_objtype, __pyx_n_s_Axle, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 343, __pyx_L1_error) + if (__pyx_t_2) { + + /* "detect.py":344 + * objname += str(iteml) + * if objtype == "Axle": + * output = "{:.2f}in".format(iteml) # <<<<<<<<<<<<<< + * objname += str(itemwr) + * #print(objname) + */ + __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_2f_in, __pyx_n_s_format); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 344, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_15); + if (unlikely(!__pyx_v_iteml)) { __Pyx_RaiseUnboundLocalError("iteml"); __PYX_ERR(0, 344, __pyx_L1_error) } + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_15))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_15); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_15, function); } - __pyx_L95:; + } + __pyx_t_6 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_15, __pyx_t_3, __pyx_v_iteml) : __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_v_iteml); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 344, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_DECREF_SET(__pyx_v_output, __pyx_t_6); + __pyx_t_6 = 0; - /* "detect.py":341 - * ), cv2.FONT_HERSHEY_SIMPLEX, - * 0.6, (50, 50, 220), 2) - * output = "" # <<<<<<<<<<<<<< - * objname = objtype; - * if objtype == "Unknown": + /* "detect.py":345 + * if objtype == "Axle": + * output = "{:.2f}in".format(iteml) + * objname += str(itemwr) # <<<<<<<<<<<<<< + * #print(objname) + * list.append(objname) */ - __Pyx_INCREF(__pyx_kp_s__3); - __Pyx_XDECREF_SET(__pyx_v_output, __pyx_kp_s__3); + __pyx_t_6 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_itemwr); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 345, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_15 = PyNumber_InPlaceAdd(__pyx_v_objname, __pyx_t_6); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 345, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF_SET(__pyx_v_objname, __pyx_t_15); + __pyx_t_15 = 0; - /* "detect.py":342 - * 0.6, (50, 50, 220), 2) - * output = "" - * objname = objtype; # <<<<<<<<<<<<<< - * if objtype == "Unknown": - * output = "{:.2f}in".format(itemw) + " x {:.2f}in".format(itemh) + /* "detect.py":343 + * output = str(iteml) + "in" + * objname += str(iteml) + * if objtype == "Axle": # <<<<<<<<<<<<<< + * output = "{:.2f}in".format(iteml) + * objname += str(itemwr) */ - __Pyx_INCREF(__pyx_v_objtype); - __Pyx_DECREF_SET(__pyx_v_objname, __pyx_v_objtype); + } - /* "detect.py":343 - * output = "" - * objname = objtype; - * if objtype == "Unknown": # <<<<<<<<<<<<<< - * output = "{:.2f}in".format(itemw) + " x {:.2f}in".format(itemh) - * if objtype == "Screw" or objtype == "Standoff": + /* "detect.py":347 + * objname += str(itemwr) + * #print(objname) + * list.append(objname) # <<<<<<<<<<<<<< + * if circular: + * cv2.putText(orig, output, # print data */ - __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_objtype, __pyx_n_s_Unknown, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 343, __pyx_L1_error) - if (__pyx_t_2) { - - /* "detect.py":344 - * objname = objtype; - * if objtype == "Unknown": - * output = "{:.2f}in".format(itemw) + " x {:.2f}in".format(itemh) # <<<<<<<<<<<<<< - * if objtype == "Screw" or objtype == "Standoff": - * output = str(iteml) + "in" - */ - __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_2f_in, __pyx_n_s_format); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 344, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_6 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_15))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_15); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_15, function); - } - } - __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_15, __pyx_t_6, __pyx_v_itemw) : __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_v_itemw); - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 344, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_x_2f_in, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 344, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_10 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { - __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6); - if (likely(__pyx_t_10)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); - __Pyx_INCREF(__pyx_t_10); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_6, function); - } - } - __pyx_t_15 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_10, __pyx_v_itemh) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_itemh); - __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; - if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 344, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyNumber_Add(__pyx_t_3, __pyx_t_15); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 344, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __Pyx_DECREF_SET(__pyx_v_output, __pyx_t_6); - __pyx_t_6 = 0; + __pyx_t_16 = __Pyx_PyList_Append(__pyx_v_list, __pyx_v_objname); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 347, __pyx_L1_error) - /* "detect.py":343 - * output = "" - * objname = objtype; - * if objtype == "Unknown": # <<<<<<<<<<<<<< - * output = "{:.2f}in".format(itemw) + " x {:.2f}in".format(itemh) - * if objtype == "Screw" or objtype == "Standoff": + /* "detect.py":348 + * #print(objname) + * list.append(objname) + * if circular: # <<<<<<<<<<<<<< + * cv2.putText(orig, output, # print data + * (int(x - 25), int(y + radius + 40) */ - } + __pyx_t_2 = (__pyx_v_circular != 0); + if (__pyx_t_2) { - /* "detect.py":345 - * if objtype == "Unknown": - * output = "{:.2f}in".format(itemw) + " x {:.2f}in".format(itemh) - * if objtype == "Screw" or objtype == "Standoff": # <<<<<<<<<<<<<< - * output = str(iteml) + "in" - * objname += str(iteml) + /* "detect.py":349 + * list.append(objname) + * if circular: + * cv2.putText(orig, output, # print data # <<<<<<<<<<<<<< + * (int(x - 25), int(y + radius + 40) + * ), cv2.FONT_HERSHEY_SIMPLEX, */ - __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_objtype, __pyx_n_s_Screw, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 345, __pyx_L1_error) - if (!__pyx_t_8) { - } else { - __pyx_t_2 = __pyx_t_8; - goto __pyx_L98_bool_binop_done; - } - __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_objtype, __pyx_n_s_Standoff, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 345, __pyx_L1_error) - __pyx_t_2 = __pyx_t_8; - __pyx_L98_bool_binop_done:; - if (__pyx_t_2) { - - /* "detect.py":346 - * output = "{:.2f}in".format(itemw) + " x {:.2f}in".format(itemh) - * if objtype == "Screw" or objtype == "Standoff": - * output = str(iteml) + "in" # <<<<<<<<<<<<<< - * objname += str(iteml) - * if objtype == "Axle": - */ - if (unlikely(!__pyx_v_iteml)) { __Pyx_RaiseUnboundLocalError("iteml"); __PYX_ERR(0, 346, __pyx_L1_error) } - __pyx_t_6 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_iteml); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 346, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_15 = PyNumber_Add(__pyx_t_6, __pyx_n_s_in); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 346, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF_SET(__pyx_v_output, __pyx_t_15); - __pyx_t_15 = 0; - - /* "detect.py":347 - * if objtype == "Screw" or objtype == "Standoff": - * output = str(iteml) + "in" - * objname += str(iteml) # <<<<<<<<<<<<<< - * if objtype == "Axle": - * output = "{:.2f}in".format(iteml) - */ - if (unlikely(!__pyx_v_iteml)) { __Pyx_RaiseUnboundLocalError("iteml"); __PYX_ERR(0, 347, __pyx_L1_error) } - __pyx_t_15 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_iteml); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 347, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_v_objname, __pyx_t_15); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 347, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __Pyx_DECREF_SET(__pyx_v_objname, __pyx_t_6); - __pyx_t_6 = 0; - - /* "detect.py":345 - * if objtype == "Unknown": - * output = "{:.2f}in".format(itemw) + " x {:.2f}in".format(itemh) - * if objtype == "Screw" or objtype == "Standoff": # <<<<<<<<<<<<<< - * output = str(iteml) + "in" - * objname += str(iteml) - */ - } - - /* "detect.py":348 - * output = str(iteml) + "in" - * objname += str(iteml) - * if objtype == "Axle": # <<<<<<<<<<<<<< - * output = "{:.2f}in".format(iteml) - * objname += str(itemwr) - */ - __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_objtype, __pyx_n_s_Axle, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 348, __pyx_L1_error) - if (__pyx_t_2) { + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_cv2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 349, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_putText); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 349, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "detect.py":349 - * objname += str(iteml) - * if objtype == "Axle": - * output = "{:.2f}in".format(iteml) # <<<<<<<<<<<<<< - * objname += str(itemwr) - * print(objname) - */ - __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_2f_in, __pyx_n_s_format); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 349, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_15); - if (unlikely(!__pyx_v_iteml)) { __Pyx_RaiseUnboundLocalError("iteml"); __PYX_ERR(0, 349, __pyx_L1_error) } - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_15))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_15); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_15, function); - } - } - __pyx_t_6 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_15, __pyx_t_3, __pyx_v_iteml) : __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_v_iteml); - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 349, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __Pyx_DECREF_SET(__pyx_v_output, __pyx_t_6); - __pyx_t_6 = 0; - - /* "detect.py":350 - * if objtype == "Axle": - * output = "{:.2f}in".format(iteml) - * objname += str(itemwr) # <<<<<<<<<<<<<< - * print(objname) - * if circular: - */ - __pyx_t_6 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_itemwr); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 350, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_15 = PyNumber_InPlaceAdd(__pyx_v_objname, __pyx_t_6); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 350, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF_SET(__pyx_v_objname, __pyx_t_15); - __pyx_t_15 = 0; - - /* "detect.py":348 - * output = str(iteml) + "in" - * objname += str(iteml) - * if objtype == "Axle": # <<<<<<<<<<<<<< - * output = "{:.2f}in".format(iteml) - * objname += str(itemwr) - */ - } - - /* "detect.py":351 - * output = "{:.2f}in".format(iteml) - * objname += str(itemwr) - * print(objname) # <<<<<<<<<<<<<< - * if circular: - * cv2.putText(orig, output, # print data - */ - if (__Pyx_PrintOne(0, __pyx_v_objname) < 0) __PYX_ERR(0, 351, __pyx_L1_error) - - /* "detect.py":352 - * objname += str(itemwr) - * print(objname) - * if circular: # <<<<<<<<<<<<<< - * cv2.putText(orig, output, # print data - * (int(x - 25), int(y + radius + 40) - */ - __pyx_t_2 = (__pyx_v_circular != 0); - if (__pyx_t_2) { + /* "detect.py":350 + * if circular: + * cv2.putText(orig, output, # print data + * (int(x - 25), int(y + radius + 40) # <<<<<<<<<<<<<< + * ), cv2.FONT_HERSHEY_SIMPLEX, + * 0.5, (50, 50, 220), 1) + */ + __pyx_t_6 = __Pyx_PyInt_SubtractObjC(__pyx_v_x, __pyx_int_25, 25, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 350, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_10 = __Pyx_PyNumber_Int(__pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 350, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = PyNumber_Add(__pyx_v_y, __pyx_v_radius); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 350, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_t_6, __pyx_int_40, 40, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 350, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 350, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 350, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_6); + __pyx_t_10 = 0; + __pyx_t_6 = 0; - /* "detect.py":353 - * print(objname) - * if circular: - * cv2.putText(orig, output, # print data # <<<<<<<<<<<<<< - * (int(x - 25), int(y + radius + 40) - * ), cv2.FONT_HERSHEY_SIMPLEX, + /* "detect.py":351 + * cv2.putText(orig, output, # print data + * (int(x - 25), int(y + radius + 40) + * ), cv2.FONT_HERSHEY_SIMPLEX, # <<<<<<<<<<<<<< + * 0.5, (50, 50, 220), 1) + * else: */ - __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_cv2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 353, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_putText); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 353, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - - /* "detect.py":354 - * if circular: - * cv2.putText(orig, output, # print data - * (int(x - 25), int(y + radius + 40) # <<<<<<<<<<<<<< - * ), cv2.FONT_HERSHEY_SIMPLEX, - * 0.5, (50, 50, 220), 1) - */ - __pyx_t_6 = __Pyx_PyInt_SubtractObjC(__pyx_v_x, __pyx_int_25, 25, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 354, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_10 = __Pyx_PyNumber_Int(__pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 354, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyNumber_Add(__pyx_v_y, __pyx_v_radius); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 354, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_t_6, __pyx_int_40, 40, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 354, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 354, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 354, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_10); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_6); - __pyx_t_10 = 0; - __pyx_t_6 = 0; - - /* "detect.py":355 - * cv2.putText(orig, output, # print data - * (int(x - 25), int(y + radius + 40) - * ), cv2.FONT_HERSHEY_SIMPLEX, # <<<<<<<<<<<<<< - * 0.5, (50, 50, 220), 1) - * else: - */ - __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_cv2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 355, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_FONT_HERSHEY_SIMPLEX); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 355, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - - /* "detect.py":356 - * (int(x - 25), int(y + radius + 40) - * ), cv2.FONT_HERSHEY_SIMPLEX, - * 0.5, (50, 50, 220), 1) # <<<<<<<<<<<<<< - * else: - * cv2.putText(orig, output, # print data - */ - __pyx_t_6 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[8] = {__pyx_t_6, __pyx_v_orig, __pyx_v_output, __pyx_t_1, __pyx_t_10, __pyx_float_0_5, __pyx_tuple__8, __pyx_int_1}; - __pyx_t_15 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 7+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 353, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[8] = {__pyx_t_6, __pyx_v_orig, __pyx_v_output, __pyx_t_1, __pyx_t_10, __pyx_float_0_5, __pyx_tuple__8, __pyx_int_1}; - __pyx_t_15 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 7+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 353, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } else - #endif - { - __pyx_t_11 = PyTuple_New(7+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 353, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - if (__pyx_t_6) { - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6); __pyx_t_6 = NULL; - } - __Pyx_INCREF(__pyx_v_orig); - __Pyx_GIVEREF(__pyx_v_orig); - PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_9, __pyx_v_orig); - __Pyx_INCREF(__pyx_v_output); - __Pyx_GIVEREF(__pyx_v_output); - PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_9, __pyx_v_output); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_9, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_9, __pyx_t_10); - __Pyx_INCREF(__pyx_float_0_5); - __Pyx_GIVEREF(__pyx_float_0_5); - PyTuple_SET_ITEM(__pyx_t_11, 4+__pyx_t_9, __pyx_float_0_5); - __Pyx_INCREF(__pyx_tuple__8); - __Pyx_GIVEREF(__pyx_tuple__8); - PyTuple_SET_ITEM(__pyx_t_11, 5+__pyx_t_9, __pyx_tuple__8); - __Pyx_INCREF(__pyx_int_1); - __Pyx_GIVEREF(__pyx_int_1); - PyTuple_SET_ITEM(__pyx_t_11, 6+__pyx_t_9, __pyx_int_1); - __pyx_t_1 = 0; - __pyx_t_10 = 0; - __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 353, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_cv2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 351, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_FONT_HERSHEY_SIMPLEX); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 351, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "detect.py":352 - * objname += str(itemwr) - * print(objname) - * if circular: # <<<<<<<<<<<<<< - * cv2.putText(orig, output, # print data - * (int(x - 25), int(y + radius + 40) + /* "detect.py":352 + * (int(x - 25), int(y + radius + 40) + * ), cv2.FONT_HERSHEY_SIMPLEX, + * 0.5, (50, 50, 220), 1) # <<<<<<<<<<<<<< + * else: + * cv2.putText(orig, output, # print data */ - goto __pyx_L101; + __pyx_t_6 = NULL; + __pyx_t_9 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + __pyx_t_9 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[8] = {__pyx_t_6, __pyx_v_orig, __pyx_v_output, __pyx_t_1, __pyx_t_10, __pyx_float_0_5, __pyx_tuple__8, __pyx_int_1}; + __pyx_t_15 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 7+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 349, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[8] = {__pyx_t_6, __pyx_v_orig, __pyx_v_output, __pyx_t_1, __pyx_t_10, __pyx_float_0_5, __pyx_tuple__8, __pyx_int_1}; + __pyx_t_15 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 7+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 349, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } else + #endif + { + __pyx_t_11 = PyTuple_New(7+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 349, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + if (__pyx_t_6) { + __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6); __pyx_t_6 = NULL; } + __Pyx_INCREF(__pyx_v_orig); + __Pyx_GIVEREF(__pyx_v_orig); + PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_9, __pyx_v_orig); + __Pyx_INCREF(__pyx_v_output); + __Pyx_GIVEREF(__pyx_v_output); + PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_9, __pyx_v_output); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_9, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_9, __pyx_t_10); + __Pyx_INCREF(__pyx_float_0_5); + __Pyx_GIVEREF(__pyx_float_0_5); + PyTuple_SET_ITEM(__pyx_t_11, 4+__pyx_t_9, __pyx_float_0_5); + __Pyx_INCREF(__pyx_tuple__8); + __Pyx_GIVEREF(__pyx_tuple__8); + PyTuple_SET_ITEM(__pyx_t_11, 5+__pyx_t_9, __pyx_tuple__8); + __Pyx_INCREF(__pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_11, 6+__pyx_t_9, __pyx_int_1); + __pyx_t_1 = 0; + __pyx_t_10 = 0; + __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 349, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - /* "detect.py":358 - * 0.5, (50, 50, 220), 1) - * else: - * cv2.putText(orig, output, # print data # <<<<<<<<<<<<<< - * (int(xpos2 + 10), int(ypos2 + 40) - * ), cv2.FONT_HERSHEY_SIMPLEX, + /* "detect.py":348 + * #print(objname) + * list.append(objname) + * if circular: # <<<<<<<<<<<<<< + * cv2.putText(orig, output, # print data + * (int(x - 25), int(y + radius + 40) */ - /*else*/ { - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_cv2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 358, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_putText); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 358, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L95; + } - /* "detect.py":359 - * else: - * cv2.putText(orig, output, # print data - * (int(xpos2 + 10), int(ypos2 + 40) # <<<<<<<<<<<<<< - * ), cv2.FONT_HERSHEY_SIMPLEX, - * 0.5, (50, 50, 220), 1) + /* "detect.py":354 + * 0.5, (50, 50, 220), 1) + * else: + * cv2.putText(orig, output, # print data # <<<<<<<<<<<<<< + * (int(xpos2 + 10), int(ypos2 + 40) + * ), cv2.FONT_HERSHEY_SIMPLEX, */ - __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_v_xpos2, __pyx_int_10, 10, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 359, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_10 = __Pyx_PyNumber_Int(__pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 359, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_v_ypos2, __pyx_int_40, 40, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 359, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 359, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 359, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_GIVEREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_10); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); - __pyx_t_10 = 0; - __pyx_t_1 = 0; + /*else*/ { + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_cv2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 354, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_putText); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 354, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "detect.py":360 - * cv2.putText(orig, output, # print data - * (int(xpos2 + 10), int(ypos2 + 40) - * ), cv2.FONT_HERSHEY_SIMPLEX, # <<<<<<<<<<<<<< - * 0.5, (50, 50, 220), 1) - * + /* "detect.py":355 + * else: + * cv2.putText(orig, output, # print data + * (int(xpos2 + 10), int(ypos2 + 40) # <<<<<<<<<<<<<< + * ), cv2.FONT_HERSHEY_SIMPLEX, + * 0.5, (50, 50, 220), 1) */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_cv2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_FONT_HERSHEY_SIMPLEX); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 360, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_v_xpos2, __pyx_int_10, 10, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 355, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_10 = __Pyx_PyNumber_Int(__pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 355, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_v_ypos2, __pyx_int_40, 40, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 355, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 355, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 355, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); + __pyx_t_10 = 0; + __pyx_t_1 = 0; - /* "detect.py":361 - * (int(xpos2 + 10), int(ypos2 + 40) - * ), cv2.FONT_HERSHEY_SIMPLEX, - * 0.5, (50, 50, 220), 1) # <<<<<<<<<<<<<< - * - * # show the output image + /* "detect.py":356 + * cv2.putText(orig, output, # print data + * (int(xpos2 + 10), int(ypos2 + 40) + * ), cv2.FONT_HERSHEY_SIMPLEX, # <<<<<<<<<<<<<< + * 0.5, (50, 50, 220), 1) + * # show the output image */ - __pyx_t_1 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) { - __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11); - if (likely(__pyx_t_1)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); - __Pyx_INCREF(__pyx_t_1); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_11, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_11)) { - PyObject *__pyx_temp[8] = {__pyx_t_1, __pyx_v_orig, __pyx_v_output, __pyx_t_3, __pyx_t_10, __pyx_float_0_5, __pyx_tuple__8, __pyx_int_1}; - __pyx_t_15 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_9, 7+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 358, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { - PyObject *__pyx_temp[8] = {__pyx_t_1, __pyx_v_orig, __pyx_v_output, __pyx_t_3, __pyx_t_10, __pyx_float_0_5, __pyx_tuple__8, __pyx_int_1}; - __pyx_t_15 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_9, 7+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 358, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } else - #endif - { - __pyx_t_6 = PyTuple_New(7+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 358, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - if (__pyx_t_1) { - __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __pyx_t_1 = NULL; - } - __Pyx_INCREF(__pyx_v_orig); - __Pyx_GIVEREF(__pyx_v_orig); - PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_9, __pyx_v_orig); - __Pyx_INCREF(__pyx_v_output); - __Pyx_GIVEREF(__pyx_v_output); - PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_9, __pyx_v_output); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_9, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_9, __pyx_t_10); - __Pyx_INCREF(__pyx_float_0_5); - __Pyx_GIVEREF(__pyx_float_0_5); - PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_9, __pyx_float_0_5); - __Pyx_INCREF(__pyx_tuple__8); - __Pyx_GIVEREF(__pyx_tuple__8); - PyTuple_SET_ITEM(__pyx_t_6, 5+__pyx_t_9, __pyx_tuple__8); - __Pyx_INCREF(__pyx_int_1); - __Pyx_GIVEREF(__pyx_int_1); - PyTuple_SET_ITEM(__pyx_t_6, 6+__pyx_t_9, __pyx_int_1); - __pyx_t_3 = 0; - __pyx_t_10 = 0; - __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_6, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 358, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - } - __pyx_L101:; + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_cv2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 356, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_FONT_HERSHEY_SIMPLEX); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 356, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "detect.py":364 - * - * # show the output image - * if show: # <<<<<<<<<<<<<< - * cv2.imshow("Item Sorter", orig) - * #cv2.waitKey(1) + /* "detect.py":357 + * (int(xpos2 + 10), int(ypos2 + 40) + * ), cv2.FONT_HERSHEY_SIMPLEX, + * 0.5, (50, 50, 220), 1) # <<<<<<<<<<<<<< + * # show the output image + * if show and not quick: */ - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_show); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 364, __pyx_L1_error) - if (__pyx_t_2) { + __pyx_t_1 = NULL; + __pyx_t_9 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) { + __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11); + if (likely(__pyx_t_1)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_11, function); + __pyx_t_9 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_11)) { + PyObject *__pyx_temp[8] = {__pyx_t_1, __pyx_v_orig, __pyx_v_output, __pyx_t_3, __pyx_t_10, __pyx_float_0_5, __pyx_tuple__8, __pyx_int_1}; + __pyx_t_15 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_9, 7+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 354, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { + PyObject *__pyx_temp[8] = {__pyx_t_1, __pyx_v_orig, __pyx_v_output, __pyx_t_3, __pyx_t_10, __pyx_float_0_5, __pyx_tuple__8, __pyx_int_1}; + __pyx_t_15 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_9, 7+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 354, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } else + #endif + { + __pyx_t_6 = PyTuple_New(7+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 354, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (__pyx_t_1) { + __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __pyx_t_1 = NULL; + } + __Pyx_INCREF(__pyx_v_orig); + __Pyx_GIVEREF(__pyx_v_orig); + PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_9, __pyx_v_orig); + __Pyx_INCREF(__pyx_v_output); + __Pyx_GIVEREF(__pyx_v_output); + PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_9, __pyx_v_output); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_9, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_9, __pyx_t_10); + __Pyx_INCREF(__pyx_float_0_5); + __Pyx_GIVEREF(__pyx_float_0_5); + PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_9, __pyx_float_0_5); + __Pyx_INCREF(__pyx_tuple__8); + __Pyx_GIVEREF(__pyx_tuple__8); + PyTuple_SET_ITEM(__pyx_t_6, 5+__pyx_t_9, __pyx_tuple__8); + __Pyx_INCREF(__pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_6, 6+__pyx_t_9, __pyx_int_1); + __pyx_t_3 = 0; + __pyx_t_10 = 0; + __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_6, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 354, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + } + __pyx_L95:; - /* "detect.py":365 - * # show the output image - * if show: - * cv2.imshow("Item Sorter", orig) # <<<<<<<<<<<<<< - * #cv2.waitKey(1) - * if quick: + /* "detect.py":359 + * 0.5, (50, 50, 220), 1) + * # show the output image + * if show and not quick: # <<<<<<<<<<<<<< + * cv2.imshow("Item Sorter", orig) + * #cv2.waitKey(1) */ - __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_cv2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 365, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_imshow); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 365, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { - __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_6); - if (likely(__pyx_t_11)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); - __Pyx_INCREF(__pyx_t_11); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_6, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_6)) { - PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_kp_s_Item_Sorter, __pyx_v_orig}; - __pyx_t_15 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 365, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_GOTREF(__pyx_t_15); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { - PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_kp_s_Item_Sorter, __pyx_v_orig}; - __pyx_t_15 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 365, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_GOTREF(__pyx_t_15); - } else - #endif - { - __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 365, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - if (__pyx_t_11) { - __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11); __pyx_t_11 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_Item_Sorter); - __Pyx_GIVEREF(__pyx_kp_s_Item_Sorter); - PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_kp_s_Item_Sorter); - __Pyx_INCREF(__pyx_v_orig); - __Pyx_GIVEREF(__pyx_v_orig); - PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_v_orig); - __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 365, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_show); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 359, __pyx_L1_error) + if (__pyx_t_8) { + } else { + __pyx_t_2 = __pyx_t_8; + goto __pyx_L97_bool_binop_done; + } + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_quick); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 359, __pyx_L1_error) + __pyx_t_7 = ((!__pyx_t_8) != 0); + __pyx_t_2 = __pyx_t_7; + __pyx_L97_bool_binop_done:; + if (__pyx_t_2) { - /* "detect.py":364 - * - * # show the output image - * if show: # <<<<<<<<<<<<<< - * cv2.imshow("Item Sorter", orig) - * #cv2.waitKey(1) + /* "detect.py":360 + * # show the output image + * if show and not quick: + * cv2.imshow("Item Sorter", orig) # <<<<<<<<<<<<<< + * #cv2.waitKey(1) + * if quick: */ + __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_cv2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 360, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_imshow); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 360, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = NULL; + __pyx_t_9 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { + __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_6); + if (likely(__pyx_t_11)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); + __Pyx_INCREF(__pyx_t_11); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_6, function); + __pyx_t_9 = 1; } - - /* "detect.py":327 - * # print(str(iteml)) - * # draw the object sizes on the image - * if show or True: # <<<<<<<<<<<<<< - * # cv2.putText(orig, "{:.5f}in".format(itemhr), - * # (int(trbrX + 20), int(trbrY)), cv2.FONT_HERSHEY_SIMPLEX, - */ } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_6)) { + PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_kp_s_Item_Sorter, __pyx_v_orig}; + __pyx_t_15 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 360, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_GOTREF(__pyx_t_15); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { + PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_kp_s_Item_Sorter, __pyx_v_orig}; + __pyx_t_15 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 360, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_GOTREF(__pyx_t_15); + } else + #endif + { + __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 360, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + if (__pyx_t_11) { + __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11); __pyx_t_11 = NULL; + } + __Pyx_INCREF(__pyx_kp_s_Item_Sorter); + __Pyx_GIVEREF(__pyx_kp_s_Item_Sorter); + PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_kp_s_Item_Sorter); + __Pyx_INCREF(__pyx_v_orig); + __Pyx_GIVEREF(__pyx_v_orig); + PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_v_orig); + __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 360, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - /* "detect.py":235 - * dimB = dB / pixelsPerMetric - * - * if num == num or show: # <<<<<<<<<<<<<< - * area_box = dA * dB - * (x, y), radius = cv2.minEnclosingCircle(c) + /* "detect.py":359 + * 0.5, (50, 50, 220), 1) + * # show the output image + * if show and not quick: # <<<<<<<<<<<<<< + * cv2.imshow("Item Sorter", orig) + * #cv2.waitKey(1) */ } @@ -10366,46 +10313,54 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - /* "detect.py":367 - * cv2.imshow("Item Sorter", orig) - * #cv2.waitKey(1) + /* "detect.py":362 + * cv2.imshow("Item Sorter", orig) + * #cv2.waitKey(1) * if quick: # <<<<<<<<<<<<<< - * return orig + * return (list, orig) * else: */ - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_quick); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 367, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_quick); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 362, __pyx_L1_error) if (__pyx_t_2) { - /* "detect.py":368 - * #cv2.waitKey(1) + /* "detect.py":363 + * #cv2.waitKey(1) * if quick: - * return orig # <<<<<<<<<<<<<< + * return (list, orig) # <<<<<<<<<<<<<< * else: * cv2.waitKey(0) */ __Pyx_XDECREF(__pyx_r); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 363, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_v_list); + __Pyx_GIVEREF(__pyx_v_list); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_list); __Pyx_INCREF(__pyx_v_orig); - __pyx_r = __pyx_v_orig; + __Pyx_GIVEREF(__pyx_v_orig); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_orig); + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; goto __pyx_L0; - /* "detect.py":367 - * cv2.imshow("Item Sorter", orig) - * #cv2.waitKey(1) + /* "detect.py":362 + * cv2.imshow("Item Sorter", orig) + * #cv2.waitKey(1) * if quick: # <<<<<<<<<<<<<< - * return orig + * return (list, orig) * else: */ } - /* "detect.py":370 - * return orig + /* "detect.py":365 + * return (list, orig) * else: * cv2.waitKey(0) # <<<<<<<<<<<<<< */ /*else*/ { - __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_n_s_cv2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 370, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_n_s_cv2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_waitKey); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 370, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_waitKey); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = NULL; @@ -10420,7 +10375,7 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P } __pyx_t_5 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_15, __pyx_int_0) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_int_0); __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; - if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 370, __pyx_L1_error) + if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; @@ -10430,7 +10385,7 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P * args = vars(ap.parse_args()) * args2 = ap.parse_args()""" * def detect(calibration_width, img_file, show, quick): # <<<<<<<<<<<<<< - * selected = 2 + * list = [] * #if type(args["number"]) == type(selected): */ @@ -10449,6 +10404,7 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P __Pyx_AddTraceback("detect.detect", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; + __Pyx_XDECREF(__pyx_v_list); __Pyx_XDECREF(__pyx_v_image); __Pyx_XDECREF(__pyx_v_gray); __Pyx_XDECREF(__pyx_v_edged); @@ -10634,10 +10590,8 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_drawContours, __pyx_k_drawContours, sizeof(__pyx_k_drawContours), 0, 0, 1, 1}, {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1}, {&__pyx_n_s_edged, __pyx_k_edged, sizeof(__pyx_k_edged), 0, 0, 1, 1}, - {&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1}, {&__pyx_n_s_epsilon, __pyx_k_epsilon, sizeof(__pyx_k_epsilon), 0, 0, 1, 1}, {&__pyx_n_s_erode, __pyx_k_erode, sizeof(__pyx_k_erode), 0, 0, 1, 1}, - {&__pyx_n_s_file, __pyx_k_file, sizeof(__pyx_k_file), 0, 0, 1, 1}, {&__pyx_n_s_findContours, __pyx_k_findContours, sizeof(__pyx_k_findContours), 0, 0, 1, 1}, {&__pyx_n_s_fitLine, __pyx_k_fitLine, sizeof(__pyx_k_fitLine), 0, 0, 1, 1}, {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1}, @@ -10666,6 +10620,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_lefty, __pyx_k_lefty, sizeof(__pyx_k_lefty), 0, 0, 1, 1}, {&__pyx_n_s_linalg, __pyx_k_linalg, sizeof(__pyx_k_linalg), 0, 0, 1, 1}, {&__pyx_n_s_line, __pyx_k_line, sizeof(__pyx_k_line), 0, 0, 1, 1}, + {&__pyx_n_s_list, __pyx_k_list, sizeof(__pyx_k_list), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_n_s_mask, __pyx_k_mask, sizeof(__pyx_k_mask), 0, 0, 1, 1}, {&__pyx_n_s_math, __pyx_k_math, sizeof(__pyx_k_math), 0, 0, 1, 1}, @@ -10687,7 +10642,6 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_output, __pyx_k_output, sizeof(__pyx_k_output), 0, 0, 1, 1}, {&__pyx_n_s_pi, __pyx_k_pi, sizeof(__pyx_k_pi), 0, 0, 1, 1}, {&__pyx_n_s_pixelsPerMetric, __pyx_k_pixelsPerMetric, sizeof(__pyx_k_pixelsPerMetric), 0, 0, 1, 1}, - {&__pyx_n_s_print, __pyx_k_print, sizeof(__pyx_k_print), 0, 0, 1, 1}, {&__pyx_n_s_ptA, __pyx_k_ptA, sizeof(__pyx_k_ptA), 0, 0, 1, 1}, {&__pyx_n_s_ptB, __pyx_k_ptB, sizeof(__pyx_k_ptB), 0, 0, 1, 1}, {&__pyx_n_s_putText, __pyx_k_putText, sizeof(__pyx_k_putText), 0, 0, 1, 1}, @@ -10699,7 +10653,6 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_righty, __pyx_k_righty, sizeof(__pyx_k_righty), 0, 0, 1, 1}, {&__pyx_n_s_round, __pyx_k_round, sizeof(__pyx_k_round), 0, 0, 1, 1}, {&__pyx_n_s_rows, __pyx_k_rows, sizeof(__pyx_k_rows), 0, 0, 1, 1}, - {&__pyx_n_s_selected, __pyx_k_selected, sizeof(__pyx_k_selected), 0, 0, 1, 1}, {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1}, {&__pyx_n_s_shead, __pyx_k_shead, sizeof(__pyx_k_shead), 0, 0, 1, 1}, {&__pyx_n_s_show, __pyx_k_show, sizeof(__pyx_k_show), 0, 0, 1, 1}, @@ -10771,57 +10724,57 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_GIVEREF(__pyx_tuple__2); /* "detect.py":249 - * else: - * circular = True - * cv2.circle(orig, (int(x), int(y)), int(radius), (255, 0, 0), 2) # <<<<<<<<<<<<<< - * - * objtype = "Unknown" + * else: + * circular = True + * cv2.circle(orig, (int(x), int(y)), int(radius), (255, 0, 0), 2) # <<<<<<<<<<<<<< + * objtype = "Unknown" + * itemw = larger(dimA, dimB) */ __pyx_tuple__4 = PyTuple_Pack(3, __pyx_int_255, __pyx_int_0, __pyx_int_0); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4); - /* "detect.py":287 - * defects = cv2.convexityDefects(c, hull) - * #print(str(defects.size) + " match") - * cv2.drawContours(orig, (hull2), -1, (0, 0, 255), 3) # <<<<<<<<<<<<<< - * cv2.drawContours(orig, (approx), -1, (255, 0, 0), 3) - * convexness = area_contour / cv2.contourArea(hull2) + /* "detect.py":285 + * defects = cv2.convexityDefects(c, hull) + * #print(str(defects.size) + " match") + * cv2.drawContours(orig, (hull2), -1, (0, 0, 255), 3) # <<<<<<<<<<<<<< + * cv2.drawContours(orig, (approx), -1, (255, 0, 0), 3) + * convexness = area_contour / cv2.contourArea(hull2) */ - __pyx_tuple__5 = PyTuple_Pack(3, __pyx_int_0, __pyx_int_0, __pyx_int_255); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 287, __pyx_L1_error) + __pyx_tuple__5 = PyTuple_Pack(3, __pyx_int_0, __pyx_int_0, __pyx_int_255); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 285, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__5); __Pyx_GIVEREF(__pyx_tuple__5); - /* "detect.py":308 - * iteml = (radius * 2 / pixelsPerMetric + itemw) / 2 - * - * rows, cols = orig.shape[:2] # <<<<<<<<<<<<<< - * [vx, vy, xx, yy] = cv2.fitLine(c, cv2.DIST_L2, 0, 0.01, 0.01) - * lefty = int((-xx*vy/vx) + yy) + /* "detect.py":304 + * objtype = "Axle" + * iteml = (radius * 2 / pixelsPerMetric + itemw) / 2 + * rows, cols = orig.shape[:2] # <<<<<<<<<<<<<< + * [vx, vy, xx, yy] = cv2.fitLine(c, cv2.DIST_L2, 0, 0.01, 0.01) + * lefty = int((-xx*vy/vx) + yy) */ - __pyx_slice__6 = PySlice_New(Py_None, __pyx_int_2, Py_None); if (unlikely(!__pyx_slice__6)) __PYX_ERR(0, 308, __pyx_L1_error) + __pyx_slice__6 = PySlice_New(Py_None, __pyx_int_2, Py_None); if (unlikely(!__pyx_slice__6)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__6); __Pyx_GIVEREF(__pyx_slice__6); - /* "detect.py":324 - * if rectangular: - * cv2.line(orig, (int(xpos), int(ypos)), - * (int(xpos2), int(ypos2)), (255, 127, 0), 2) # <<<<<<<<<<<<<< - * # print(str(iteml)) - * # draw the object sizes on the image + /* "detect.py":320 + * if rectangular: + * cv2.line(orig, (int(xpos), int(ypos)), + * (int(xpos2), int(ypos2)), (255, 127, 0), 2) # <<<<<<<<<<<<<< + * # print(str(iteml)) + * # draw the object sizes on the image */ - __pyx_tuple__7 = PyTuple_Pack(3, __pyx_int_255, __pyx_int_127, __pyx_int_0); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 324, __pyx_L1_error) + __pyx_tuple__7 = PyTuple_Pack(3, __pyx_int_255, __pyx_int_127, __pyx_int_0); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 320, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__7); __Pyx_GIVEREF(__pyx_tuple__7); - /* "detect.py":335 - * (int(x - 25), int(y + radius + 20) - * ), cv2.FONT_HERSHEY_SIMPLEX, - * 0.6, (50, 50, 220), 2) # <<<<<<<<<<<<<< - * else: - * cv2.putText(orig, str(objtype), + /* "detect.py":330 + * (int(x - 25), int(y + radius + 20) + * ), cv2.FONT_HERSHEY_SIMPLEX, + * 0.6, (50, 50, 220), 2) # <<<<<<<<<<<<<< + * else: + * cv2.putText(orig, str(objtype), */ - __pyx_tuple__8 = PyTuple_Pack(3, __pyx_int_50, __pyx_int_50, __pyx_int_220); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 335, __pyx_L1_error) + __pyx_tuple__8 = PyTuple_Pack(3, __pyx_int_50, __pyx_int_50, __pyx_int_220); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 330, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__8); __Pyx_GIVEREF(__pyx_tuple__8); @@ -10913,10 +10866,10 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * args = vars(ap.parse_args()) * args2 = ap.parse_args()""" * def detect(calibration_width, img_file, show, quick): # <<<<<<<<<<<<<< - * selected = 2 + * list = [] * #if type(args["number"]) == type(selected): */ - __pyx_tuple__23 = PyTuple_Pack(71, __pyx_n_s_calibration_width, __pyx_n_s_img_file, __pyx_n_s_show, __pyx_n_s_quick, __pyx_n_s_selected, __pyx_n_s_image, __pyx_n_s_gray, __pyx_n_s_edged, __pyx_n_s_cnts, __pyx_n_s_pixelsPerMetric, __pyx_n_s_num, __pyx_n_s_c, __pyx_n_s_orig, __pyx_n_s_box, __pyx_n_s_tl, __pyx_n_s_tr, __pyx_n_s_br, __pyx_n_s_bl, __pyx_n_s_tltrX, __pyx_n_s_tltrY, __pyx_n_s_blbrX, __pyx_n_s_blbrY, __pyx_n_s_tlblX, __pyx_n_s_tlblY, __pyx_n_s_trbrX, __pyx_n_s_trbrY, __pyx_n_s_dA, __pyx_n_s_dB, __pyx_n_s_area_box, __pyx_n_s_x, __pyx_n_s_y, __pyx_n_s_radius, __pyx_n_s_area_contour, __pyx_n_s_area_circle, __pyx_n_s_boxiness, __pyx_n_s_circleness, __pyx_n_s_circular, __pyx_n_s_rectangular, __pyx_n_s_mask, __pyx_n_s_hsv, __pyx_n_s_mean_val, __pyx_n_s_objtype, __pyx_n_s_objname, __pyx_n_s_dimA, __pyx_n_s_dimB, __pyx_n_s_itemw, __pyx_n_s_itemwr, __pyx_n_s_itemh, __pyx_n_s_itemhr, __pyx_n_s_iteml, __pyx_n_s_epsilon, __pyx_n_s_approx, __pyx_n_s_hull, __pyx_n_s_hull2, __pyx_n_s_defects, __pyx_n_s_convexness, __pyx_n_s_rows, __pyx_n_s_cols, __pyx_n_s_vx, __pyx_n_s_vy, __pyx_n_s_xx, __pyx_n_s_yy, __pyx_n_s_lefty, __pyx_n_s_righty, __pyx_n_s_slope, __pyx_n_s_angle, __pyx_n_s_xpos, __pyx_n_s_ypos, __pyx_n_s_xpos2, __pyx_n_s_ypos2, __pyx_n_s_output); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 78, __pyx_L1_error) + __pyx_tuple__23 = PyTuple_Pack(71, __pyx_n_s_calibration_width, __pyx_n_s_img_file, __pyx_n_s_show, __pyx_n_s_quick, __pyx_n_s_list, __pyx_n_s_image, __pyx_n_s_gray, __pyx_n_s_edged, __pyx_n_s_cnts, __pyx_n_s_pixelsPerMetric, __pyx_n_s_num, __pyx_n_s_c, __pyx_n_s_orig, __pyx_n_s_box, __pyx_n_s_tl, __pyx_n_s_tr, __pyx_n_s_br, __pyx_n_s_bl, __pyx_n_s_tltrX, __pyx_n_s_tltrY, __pyx_n_s_blbrX, __pyx_n_s_blbrY, __pyx_n_s_tlblX, __pyx_n_s_tlblY, __pyx_n_s_trbrX, __pyx_n_s_trbrY, __pyx_n_s_dA, __pyx_n_s_dB, __pyx_n_s_area_box, __pyx_n_s_x, __pyx_n_s_y, __pyx_n_s_radius, __pyx_n_s_area_contour, __pyx_n_s_area_circle, __pyx_n_s_boxiness, __pyx_n_s_circleness, __pyx_n_s_circular, __pyx_n_s_rectangular, __pyx_n_s_mask, __pyx_n_s_hsv, __pyx_n_s_mean_val, __pyx_n_s_objtype, __pyx_n_s_objname, __pyx_n_s_dimA, __pyx_n_s_dimB, __pyx_n_s_itemw, __pyx_n_s_itemwr, __pyx_n_s_itemh, __pyx_n_s_itemhr, __pyx_n_s_iteml, __pyx_n_s_epsilon, __pyx_n_s_approx, __pyx_n_s_hull, __pyx_n_s_hull2, __pyx_n_s_defects, __pyx_n_s_convexness, __pyx_n_s_rows, __pyx_n_s_cols, __pyx_n_s_vx, __pyx_n_s_vy, __pyx_n_s_xx, __pyx_n_s_yy, __pyx_n_s_lefty, __pyx_n_s_righty, __pyx_n_s_slope, __pyx_n_s_angle, __pyx_n_s_xpos, __pyx_n_s_ypos, __pyx_n_s_xpos2, __pyx_n_s_ypos2, __pyx_n_s_output); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__23); __Pyx_GIVEREF(__pyx_tuple__23); __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(4, 0, 71, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_detect_py, __pyx_n_s_detect, 78, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 78, __pyx_L1_error) @@ -11428,7 +11381,7 @@ if (!__Pyx_RefNanny) { * args = vars(ap.parse_args()) * args2 = ap.parse_args()""" * def detect(calibration_width, img_file, show, quick): # <<<<<<<<<<<<<< - * selected = 2 + * list = [] * #if type(args["number"]) == type(selected): */ __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6detect_15detect, 0, __pyx_n_s_detect, NULL, __pyx_n_s_detect, __pyx_d, ((PyObject *)__pyx_codeobj__24)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 78, __pyx_L1_error) @@ -13845,149 +13798,6 @@ bad: } } -/* Print */ - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3 -static PyObject *__Pyx_GetStdout(void) { - PyObject *f = PySys_GetObject((char *)"stdout"); - if (!f) { - PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); - } - return f; -} -static int __Pyx_Print(PyObject* f, PyObject *arg_tuple, int newline) { - int i; - if (!f) { - if (!(f = __Pyx_GetStdout())) - return -1; - } - Py_INCREF(f); - for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) { - PyObject* v; - if (PyFile_SoftSpace(f, 1)) { - if (PyFile_WriteString(" ", f) < 0) - goto error; - } - v = PyTuple_GET_ITEM(arg_tuple, i); - if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) - goto error; - if (PyString_Check(v)) { - char *s = PyString_AsString(v); - Py_ssize_t len = PyString_Size(v); - if (len > 0) { - switch (s[len-1]) { - case ' ': break; - case '\f': case '\r': case '\n': case '\t': case '\v': - PyFile_SoftSpace(f, 0); - break; - default: break; - } - } - } - } - if (newline) { - if (PyFile_WriteString("\n", f) < 0) - goto error; - PyFile_SoftSpace(f, 0); - } - Py_DECREF(f); - return 0; -error: - Py_DECREF(f); - return -1; -} -#else -static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) { - PyObject* kwargs = 0; - PyObject* result = 0; - PyObject* end_string; - if (unlikely(!__pyx_print)) { - __pyx_print = PyObject_GetAttr(__pyx_b, __pyx_n_s_print); - if (!__pyx_print) - return -1; - } - if (stream) { - kwargs = PyDict_New(); - if (unlikely(!kwargs)) - return -1; - if (unlikely(PyDict_SetItem(kwargs, __pyx_n_s_file, stream) < 0)) - goto bad; - if (!newline) { - end_string = PyUnicode_FromStringAndSize(" ", 1); - if (unlikely(!end_string)) - goto bad; - if (PyDict_SetItem(kwargs, __pyx_n_s_end, end_string) < 0) { - Py_DECREF(end_string); - goto bad; - } - Py_DECREF(end_string); - } - } else if (!newline) { - if (unlikely(!__pyx_print_kwargs)) { - __pyx_print_kwargs = PyDict_New(); - if (unlikely(!__pyx_print_kwargs)) - return -1; - end_string = PyUnicode_FromStringAndSize(" ", 1); - if (unlikely(!end_string)) - return -1; - if (PyDict_SetItem(__pyx_print_kwargs, __pyx_n_s_end, end_string) < 0) { - Py_DECREF(end_string); - return -1; - } - Py_DECREF(end_string); - } - kwargs = __pyx_print_kwargs; - } - result = PyObject_Call(__pyx_print, arg_tuple, kwargs); - if (unlikely(kwargs) && (kwargs != __pyx_print_kwargs)) - Py_DECREF(kwargs); - if (!result) - return -1; - Py_DECREF(result); - return 0; -bad: - if (kwargs != __pyx_print_kwargs) - Py_XDECREF(kwargs); - return -1; -} -#endif - -/* PrintOne */ - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3 -static int __Pyx_PrintOne(PyObject* f, PyObject *o) { - if (!f) { - if (!(f = __Pyx_GetStdout())) - return -1; - } - Py_INCREF(f); - if (PyFile_SoftSpace(f, 0)) { - if (PyFile_WriteString(" ", f) < 0) - goto error; - } - if (PyFile_WriteObject(o, f, Py_PRINT_RAW) < 0) - goto error; - if (PyFile_WriteString("\n", f) < 0) - goto error; - Py_DECREF(f); - return 0; -error: - Py_DECREF(f); - return -1; - /* the line below is just to avoid C compiler - * warnings about unused functions */ - return __Pyx_Print(f, NULL, 0); -} -#else -static int __Pyx_PrintOne(PyObject* stream, PyObject *o) { - int res; - PyObject* arg_tuple = PyTuple_Pack(1, o); - if (unlikely(!arg_tuple)) - return -1; - res = __Pyx_Print(stream, arg_tuple, 1); - Py_DECREF(arg_tuple); - return res; -} -#endif - /* CIntFromPyVerify */ #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) diff --git a/detect.cpython-38-x86_64-linux-gnu.so b/detect.cpython-38-x86_64-linux-gnu.so new file mode 100755 index 0000000..17b5597 Binary files /dev/null and b/detect.cpython-38-x86_64-linux-gnu.so differ diff --git a/run_detect.py b/run_detect.py index 637d1ed..5ce07a9 100644 --- a/run_detect.py +++ b/run_detect.py @@ -1,4 +1,5 @@ import detect +import sort import timeit import cv2 from imutils.video import FPS @@ -22,6 +23,7 @@ def go(): break if valid: print("Found " + itema) + bin = sort.sort(itema) if not video: elapsed_time = timeit.timeit(go, number=1)/1 diff --git a/sort.py b/sort.py new file mode 100644 index 0000000..2b04a2b --- /dev/null +++ b/sort.py @@ -0,0 +1,31 @@ +# Sort items +import pickle + +def write(bins): + file = open("bins.txt","w+b") + pickle.dump(bins, file) + file.close() + +def sort(input): + file = open("bins.txt","a+b") + file.close() + file = open("bins.txt", "rb") + bins = pickle.load(file) + + + if len(bins) == 0: + bins = ['Unknown'] + file.close() + write(bins) + #file.write(str(bins)) + if bins.count(input) == 0: + bins.append(input) + bin = bins.index(input) + print(str(bins)) + print(bin) + write(bins) + return bin + +def clear(): + write(["Unknown"]) +write(["Unknown"]) \ No newline at end of file