Posts

Post not yet marked as solved
3 Replies
1.1k Views
I try to use MPSImageErode and MPSImageDilate in an app right now with SwiftUI and BigSur, Xcode 12.3 The code 				 var erodedilateKernelValues:[Float] = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 																								 0.0, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.0, 																								 0.0, 0.2, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.0, 																								 0.0, 0.2, 0.1, 0.0, 0.0, 0.0, 0.1, 0.2, 0.0, 																								 0.0, 0.2, 0.1, 0.0, 0.0, 0.0, 0.1, 0.2, 0.0, 																								 0.0, 0.2, 0.0, 0.0, 0.0, 0.0, 0.1, 0.2, 0.0, 																								 0.0, 0.2, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.0, 																								 0.0, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.0, 																								 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] 				 let dilateShader = MPSImageDilate( 						device: self.metalDevice!, 						kernelWidth:edSize, 						 kernelHeight:edSize, 						 values:&erodedilateKernelValues) 				 dilateShader.encode(commandBuffer: cmdBuf, 													sourceTexture: wipTexture!, 													destinationTexture: erodila) 				 let erodeShader = MPSImageErode( 						device: self.metalDevice!, 						kernelWidth:edSize, 						kernelHeight:edSize, 						values:&erodedilateKernelValues) 				 				 erodeShader.encode(commandBuffer: cmdBuf, 													sourceTexture: erodila, 													destinationTexture: erodila2) 				 cmdBuf.commit() 				 cmdBuf.waitUntilCompleted() 				 wipTexture = erodila2 Resulting in 		Compiler encountered an internal error: (null) ' /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/MetalPerformanceShaders/MetalPerformanceShaders-124.2.1/MPSCore/Utility/MPSLibrary.mm:338: failed assertion `MPSKernel MTLComputePipelineStateCache unable to load function DilateFilter4. 		Compiler encountered an internal error: (null) ' /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/MetalPerformanceShaders/MetalPerformanceShaders-124.2.1/MPSCore/Utility/MPSLibrary.mm:338: failed assertion `MPSKernel MTLComputePipelineStateCache unable to load function DilateFilter4. 		Compiler encountered an internal error: (null) ' when I use the filter with only Zero it actually works 				 var erodedilateKernelValues = [Float].init(repeating: 0.0, count: edSize * edSize) But I want to try different filter values to see if I can improve the analytics on an image. Any suggestions ?
Posted Last updated
.
Post not yet marked as solved
0 Replies
547 Views
Is there a working example for the new MPSImageCanny (and MPSImageEDLines) functionality ? I tried several ways (e.g. different texture sized, parameter) all leading to various errors like total freeze of my MBP under BigSur and Xcode 12.3             // Allocating sufficient space to store or data             let pointerToFloats = UnsafeMutablePointer<Float>.allocate(capacity: luminanceWeights.count)             pointerToFloats.assign(from: luminanceWeights, count: luminanceWeights.count)             let canny = MPSImageCanny(device: self.metalDevice!, linearToGrayScaleTransform: luminanceWeights, sigma: 3)             canny.useFastMode = false             canny.highThreshold = 0.8             canny.lowThreshold = 0.2 Is there any code snippet proven working I could base my work on ?
Posted Last updated
.