We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
问个问题,官方demo的Segmentation不是你这样写的。你这样写是什么意思?实验证明这么写的确会减缓启动时噪点多的问题,但也会失去部分精度。
def Segmentation(self, uint8_t[:, :] image): cdef int width = image.shape[1] cdef int height = image.shape[0] # cdef np.ndarray[uint8_t, ndim=2] segmentation = np.zeros([width, height], dtype=np.uint8) cdef uint8_t[:, :] segmentation_map = np.empty((height, width), dtype=np.uint8) # 官方的 segmentation_map每次调用不是申请为0的区域,而是复用上一次的segmentation_map cdef uint8_t *image_data_ptr = &image[0, 0] cdef uint8_t *segmentation_map_ptr = &segmentation_map[0, 0] # call C function cdef int32_t back back = c_vibe.libvibeModel_Sequential_Segmentation_8u_C1R(self.model, image_data_ptr, segmentation_map_ptr) # Error: need convert segmentation_map to numpy.array # return segmentation_map return np.asarray(segmentation_map)
下面是官方的实现
while ((char)keyboard != 'q' && (char)keyboard != 27) { /* Read the current frame. */ if (!capture.read(frame)) { cerr << "Unable to read next frame." << endl; cerr << "Exiting..." << endl; exit(EXIT_FAILURE); } if ((frameNumber % 100) == 0) { cout << "Frame number = " << frameNumber << endl; } if (frameNumber == 1) { segmentationMap = Mat(frame.rows, frame.cols, CV_8UC1); model = (vibeModel_Sequential_t*)libvibeModel_Sequential_New(); libvibeModel_Sequential_AllocInit_8u_C3R(model, frame.data, frame.cols, frame.rows); } libvibeModel_Sequential_Segmentation_8u_C3R(model, frame.data, segmentationMap.data); libvibeModel_Sequential_Update_8u_C3R(model, frame.data, segmentationMap.data); medianBlur(segmentationMap, segmentationMap, 3); /* 3x3 median filtering */ }
The text was updated successfully, but these errors were encountered:
你看一下这一行/~https://github.com/232525/ViBe.Cython/blob/master/lib_vibe/vibe-background-sequential.c#L321 ,官方实现应该也不是复用上一次结果,好像是把数据清成1,segmentation_map是每一次调用模型获取前景分割的结果,不至于需要复用的,我改的时候只是单纯的为了可以python调用这个函数,没考虑太多。
Sorry, something went wrong.
No branches or pull requests
问个问题,官方demo的Segmentation不是你这样写的。你这样写是什么意思?实验证明这么写的确会减缓启动时噪点多的问题,但也会失去部分精度。
下面是官方的实现
The text was updated successfully, but these errors were encountered: