| 129 | "); |
| 130 | |
| 131 | static PyObject * |
| 132 | Math_fft(PyObject *self, PyObject *args) |
| 133 | { |
| 134 | auto api = PyUtilApiFunction("Oii", PyRunTimeErr, __func__); |
| 135 | PyObject *pointsArg; |
| 136 | int nterms = 0; |
| 137 | int numInterpPoints = 0; |
| 138 | |
| 139 | if (!PyArg_ParseTuple(args,api.format, &pointsArg, &nterms, &numInterpPoints)) { |
| 140 | return api.argsError(); |
| 141 | } |
| 142 | |
| 143 | // [TODO:DaveP] check that other arguments are valid. |
| 144 | |
| 145 | // Get an array of points from the pointsArgs list. |
| 146 | int dim = 2; |
| 147 | auto pts = GetPointsFromList(api, pointsArg, dim, "points"); |
| 148 | if (pts == nullptr) { |
| 149 | return nullptr; |
| 150 | } |
| 151 | int nlistpts = PyList_Size(pointsArg); |
| 152 | |
| 153 | // Perform the fft operation. |
| 154 | auto mathObj = cvMath(); |
| 155 | double **terms = NULL; |
| 156 | if (mathObj.FFT(pts, nlistpts, numInterpPoints, nterms, &terms) == SV_ERROR) { |
| 157 | mathObj.deleteArray(pts,nlistpts,dim); |
| 158 | api.error("Error calculating the fft."); |
| 159 | return nullptr; |
| 160 | } |
| 161 | |
| 162 | // Create result list. |
| 163 | PyObject *pylist = PyList_New(nterms); |
| 164 | for (int i = 0; i < nterms; i++) { |
| 165 | PyObject* rr = PyList_New(dim); |
| 166 | PyList_SetItem(rr,0,PyFloat_FromDouble(terms[i][0])); |
| 167 | PyList_SetItem(rr,1,PyFloat_FromDouble(terms[i][1])); |
| 168 | PyList_SET_ITEM(pylist, i, rr); |
| 169 | } |
| 170 | |
| 171 | mathObj.deleteArray(pts,nlistpts,dim); |
| 172 | mathObj.deleteArray(terms,nterms,dim); |
| 173 | return pylist; |
| 174 | } |
| 175 | |
| 176 | //-------------------- |
| 177 | // Math_inverse_fft |
nothing calls this directly
no test coverage detected