为什么e.AcceptSocket.ReceiveAsync总是如此(Why e.AcceptSocket.ReceiveAsync alway be true)
我使用SocketAsyncEventArgs构建了一个小的Socket Server端。 但遇到一些问题,当我接受客户端套接字,然后我尝试使用e.AcceptSocket.ReceiveAsync来接收客户端信息,但我不知道为什么它始终显示为我。 这是服务器端:
private void ProcessAccept(SocketAsyncEventArgs e) { Console.WriteLine("Process Accept!"); if (e.BytesTransferred > 0) { Console.WriteLine("client online..."); } SocketAsyncEventArgs readEventArgs = new SocketAsyncEventArgs(); readEventArgs.AcceptSocket = e.AcceptSocket; readEventArgs.SetBuffer(new byte[1024], 0, 1024); readEventArgs.Completed+=readEventArgsIO_Completed; Boolean willRaiseEvent = e.AcceptSocket.ReceiveAsync(readEventArgs); if (!willRaiseEvent) { this.ProcessReceive(readEventArgs); } this.StartAccept(e); }
我的客户端只使用Connect方法连接服务器端并向其发送信息“Hello Server”。 但为什么我在这里总是“真实”?
Boolean willRaiseEvent = e.AcceptSocket.ReceiveAsync(readEventArgs);
谢谢。
I used SocketAsyncEventArgs to build a tiny Socket Server side. but encountering some problems, when I accepted the client socket, then I tried to use e.AcceptSocket.ReceiveAsync to receive client side info, but I don't know why it always show True to me. here is the server side:
private void ProcessAccept(SocketAsyncEventArgs e) { Console.WriteLine("Process Accept!"); if (e.BytesTransferred > 0) { Console.WriteLine("client online..."); } SocketAsyncEventArgs readEventArgs = new SocketAsyncEventArgs(); readEventArgs.AcceptSocket = e.AcceptSocket; readEventArgs.SetBuffer(new byte[1024], 0, 1024); readEventArgs.Completed+=readEventArgsIO_Completed; Boolean willRaiseEvent = e.AcceptSocket.ReceiveAsync(readEventArgs); if (!willRaiseEvent) { this.ProcessReceive(readEventArgs); } this.StartAccept(e); }
my client side only use the Connect method to connect the server side and send info "Hello Server" to it. but why I am here always got "True"?
Boolean willRaiseEvent = e.AcceptSocket.ReceiveAsync(readEventArgs);
thx.
原文:https://stackoverflow.com/questions/15945261
最满意答案
计算出水平和垂直分量后,我们有一个实数和一个虚数值(a + bi):
velocityHx(i) = real(OpticalFlow{i,1}); velocityVy(i) = imag(OpticalFlow{i,1});
如果你想要OpticalFlow值的大小,你只需要计算绝对值,就像在数学中一样:
velocityMagnitudeCentroide(i) = velocityHx(i)*velocityHx(i) + velocityVy(i)*velocityVy(i);
Once you have calculated the Horizontal and Vertical Components, we have a real and an imaginary value (a+bi):
velocityHx(i) = real(OpticalFlow{i,1}); velocityVy(i) = imag(OpticalFlow{i,1});
If you want the magnitude of the value of the OpticalFlow, you just need to calculate the absolute value, just like in Mathematics:
velocityMagnitudeCentroide(i) = velocityHx(i)*velocityHx(i) + velocityVy(i)*velocityVy(i);
相关问答
更多-
跟踪定义了计算机视觉任务,其目标是跟踪给定对象,交互区域或视频序列的连续图像中的点。 一种非常简单的方法将基于通过光流估计方法估计的运动矢量。 然而,这将在非常合作的环境条件下产生良好的结果。 如果对象被遮挡,它将失败。 最新的现有技术方法更加稳健,例如基于卡尔曼滤波器,微粒滤波器或PHD滤波器技术。 关于对象跟踪或对象跟踪的调查:通过调查 ,您可以更好地了解当前对象跟踪方法的挑战和解决方案。 Tracking defines a computer vision task with the goal to ...
-
2D convolution是这里的方式,正如在问题中预测的那样,以取代那些重mean/average计算。 此外,这些迭代差异可以用MATLAB的diff代替。 因此,结合所有这些,矢量化实施将是 - %// Pad images to handle edge cases img1 = padarray(img1, [1,1], 'post'); img2 = padarray(img2, [1,1], 'post'); %// Store size parameters for later usage ...
-
estimateFlow返回一个opticalFlow对象,该对象具有幅度,相位和速度的属性。 因此,在您的情况下, flow是一个opticalFlow对象,而不是一个复杂的数组,并且您不能将它传递给real和imag 。 而是使用对象的属性: flow.Vx % x component of velocity flow.Vy % y component of velocity flow.Orientation % Phase flow.Magnitude % Ma ...
-
光流(OF)是围绕所谓的“亮度恒定假设”的方法。 你假设像素 - 更具体,他们的强度(达到一些三角洲) - 不会改变,只会移动。 你找到了这个等式的解:I(x,y,t)= I(x + dx,y + dy,t + dt)。 裁缝系列的第一顺序是:I(x + dx,y + dy,t + dt)= I(x,y,t)+ I_x * dx + I_y * dy + I_t * dt。 然后你解出这个方程,并得到每个像素的dx和dy - 移位。 光流主要用于跟踪和测距 。 upd:如果不应用于整个图像,但补丁,光流几乎 ...
-
是的,Matlab / C ++: http : //people.csail.mit.edu/celiu/OpticalFlow/ CS UMD EDU: http : //www.cs.umd.edu/~ogale/download/code.html 我通过谷歌搜索发现了更多的参考。 希望有所帮助。 Yes, Matlab/C++: http://people.csail.mit.edu/celiu/OpticalFlow/ CS UMD EDU: http://www.cs.umd.edu/~oga ...
-
两帧之间密集的光流(Dense optical flow between two frames)[2022-02-05]
Thuis线 cvtColor(frame2, cflow, COLOR_GRAY2BGR); 可能是罪魁祸首。 在上面的一行上,使用frame2 = imread("./car2.jpg", IMREAD_COLOR);加载为彩色图像frame2 = imread("./car2.jpg", IMREAD_COLOR); 但现在你试图将它从灰色转换而来 ,这似乎是不合逻辑的。 Thuis line cvtColor(frame2, cflow, COLOR_GRAY2BGR); is probably ... -
光流的测试模式(Test patterns for optical flow)[2021-12-31]
有许多光流量基准测试可以获取样品。 最常见的是Middlebury , KITTI2012 / 2015 , SIntel和HAMA数据集/基准。 但是最近的光学流动方法难以应对大的运动,不同的照明和低对比度/纹理。 There are a lot of Optical Flow benchmarks where you can get samples. The most common are Middlebury, the KITTI2012/2015, SIntel and the HAMA datas ... -
计算出水平和垂直分量后,我们有一个实数和一个虚数值(a + bi): velocityHx(i) = real(OpticalFlow{i,1}); velocityVy(i) = imag(OpticalFlow{i,1}); 如果你想要OpticalFlow值的大小,你只需要计算绝对值,就像在数学中一样: velocityMagnitudeCentroide(i) = velocityHx(i)*velocityHx(i) + velocityVy(i)*velocityVy(i); Once you ...
-
我不了解OpenCV,但在这里找到matlab实现。 I dont know about OpenCV, but find matlab implementations here.
-
Brox密集光流跟踪器错误'EFilterIncompatibleSize'(Brox Dense Optical Flow tracker error 'EFilterIncompatibleSize')[2022-04-25]
在对作者进行了一些挖掘和联系之后,结果发现当向跟踪器提供不同大小的图像时会引起该错误。 容器大小与图像的像素尺寸有关。 就我而言,我相信我的所有图像都具有相同的尺寸,因为它们是裁剪程序的输出。 但是,一些自动裁剪的区域非常接近图像边界,因此裁剪会截断它们,从而导致裁剪区域变小,这里和那里有几个像素。 如果您遇到此错误,这是我要检查的第一件事。 After some more digging and contacting the author, it turns out that this error is ...