有效地找到一条线的斜率

时间:2018-11-29 00:39:18

标签: algorithm pattern-matching linear-regression gesture

我有一系列AttributeError: __enter__数据点:也许是视频中物体的位置,或者是用户手指在触摸屏上的位置。我需要确定该对象/触摸/等是否沿大约直线移动,以及哪个方向(角度,坡度或任何其他表示形式起作用)。

我的第一个想法是根据(cha_env36) C:\Users\antoi\Documents\Programming\Nathalie\Chatbot_RASA_room_reservation>python dialogue_management_model.py ... Epoch 99/100 90/90 [==============================] - 0s 222us/step - loss: 0.5290 - acc: 0.8889 - val_loss: 0.8006 - val_acc: 0.8261 Epoch 100/100 90/90 [==============================] - 0s 211us/step - loss: 0.5154 - acc: 0.9000 - val_loss: 0.7957 - val_acc: 0.7826 Bot loaded. Type a message and press enter (use '/stop' to exit): Hello ! C:\Users\antoi\Documents\Programming\Nathalie\Chatbot_RASA_room_reservation\cha_env36\lib\site-packages\sklearn\preprocessing\label.py:151: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty. if diff: 127.0.0.1 - - [2018-11-28 23:36:40] "POST /webhooks/rest/webhook?stream=true&token= HTTP/1.1" 200 153 0.891224 Traceback (most recent call last): File "C:\Python36\lib\multiprocessing\queues.py", line 236, in _feed send_bytes(obj) File "C:\Python36\lib\multiprocessing\connection.py", line 200, in send_bytes self._send_bytes(m[offset:offset + size]) File "C:\Python36\lib\multiprocessing\connection.py", line 280, in _send_bytes ov, err = _winapi.WriteFile(self._handle, buf, overlapped=True) BrokenPipeError: [WinError 232] The pipe is being closed Exception in thread Thread-7: Traceback (most recent call last): File "C:\Python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\Python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Users\antoi\Documents\Programming\Nathalie\Chatbot_RASA_room_reservation\cha_env36\lib\site-packages\rasa_core\channels\console.py", line 110, in record_messages for response in bot_responses: File "C:\Users\antoi\Documents\Programming\Nathalie\Chatbot_RASA_room_reservation\cha_env36\lib\site-packages\rasa_core\channels\console.py", line 67, in send_message_receive_stream stream=True) as r: AttributeError: __enter__ (样本的索引)对(x,y)进行线性回归,对x进行t进行线性回归以获得斜率,然后使用相关系数确定数据的线性度。但这需要在嵌入式硬件上连续运行,并且这些计算相当昂贵。

考虑到y轴几乎无关紧要,我可以采取任何捷径吗?例如,用t进行t的线性回归会更有效,但是会遇到垂直和接近垂直线的问题。

2 个答案:

答案 0 :(得分:3)

我对廉价测试的第一个想法是计算每对连续点之间的线段的角度(相对于X轴),如果它们之间的差异超过允许的误差,则称其为非​​直线

这将允许柔和的曲线通过测试,因此最好将新斜率与旧斜率的低通滤波版本进行比较。

答案 1 :(得分:0)

找到起点和终点之间的直线方程。现在计算从每个点到该线的垂直距离。如果每个的垂直距离都在公差值之内,则可以将其视为一条直线。