Gaussian BLUR implemented in cocos2d! (5

 

Gaussian BLUR implemented in cocos2d!

http://www.cocos2d-iphone.org/forum/topic/6315

To apply Gaussian blur on a video using OpenCV with CUDA in Python, you can use the following code: ```python import cv2 # Open the video file cap = cv2.VideoCapture('video.mp4') # Create a CUDA enabled Gaussian Blur filter blur = cv2.cuda.createGaussianFilter(cv2.CV_8UC3, (15, 15), 0, 0, cv2.BORDER_DEFAULT) while True: # Read a frame from the video ret, frame = cap.read() if not ret: break # Convert the frame to CUDA format frame_cuda = cv2.cuda_GpuMat() frame_cuda.upload(frame) # Apply Gaussian Blur blurred_cuda = blur.apply(frame_cuda) # Download the result back to CPU memory blurred = blurred_cuda.download() # Display the result cv2.imshow('Gaussian Blur', blurred) # Wait for the user to press 'q' to quit if cv2.waitKey(1) & 0xFF == ord('q'): break # Release the video file and close the window cap.release() cv2.destroyAllWindows() ``` In this code, we first open the video file using `cv2.VideoCapture()`. We then create a CUDA enabled Gaussian Blur filter using `cv2.cuda.createGaussianFilter()`. Inside the loop, we read a frame from the video and convert it to CUDA format using `cv2.cuda_GpuMat()`. We apply Gaussian blur using the filter we created earlier and download the result back to CPU memory using `download()`. Finally, we display the result using `cv2.imshow()` and wait for the user to press 'q' to quit. Note that you need to have OpenCV with CUDA support installed for this code to work. Also, you may need to adjust the kernel size and other parameters of the Gaussian Blur filter to get the desired effect.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值