/ Published in: C#
                    
                                        Given a UMat we sometimes need to find the most common value in that UMat. This code does it the unsafe (fast) way.
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
 byte mostCommonValue; fixed (byte* buffer = umat.Bytes) { byte* end = buffer + umat.Bytes.Length; for (byte* pointer = buffer; pointer != end; pointer++) { counters[*pointer]++; } mostCommonValue = (byte)Array.IndexOf(counters, counters.Max()); }
Comments
                    Subscribe to comments
                
                