How to blurring detected text in OCR Text Detection and Extraction Add-on
Problem: I want to blur a text on the image and I follow document of Cloundinary (https://cloudinary.com/documentation/ocr_text_detection_and_extraction_addon#blurring_or_pixelating_detected_text)
I'm using Ruby code like below:
cl_image_tag("smartphone2.jpg", :effect=>"blur_region:800", :gravity=>"ocr_text")
But I do not understand value 800 in blur_region:800 - and how to get the value from the random image.
Please support me about that.
-
Hi Luan,
For the 'blur_region' effect, the number is a parameter which controls the level of blur which will be applied to the selection region.
It's described in the Image Transformation Reference documentation here: https://cloudinary.com/documentation/image_transformation_reference#effect_parameter
The value can be from 0 to 2000, and you can choose a value yourself depending on your requirements - most likely you will not need to set a different value for different images, but choose one based on how much blurring you need.
Please take a look and let me know if that helps!
1 -
Yes, thanks for your answer, I got it that value from blur_region after read Transformation Reference documentation.
So now I still in problem: I have a lot of different images which contain some text and I want to use OCR Text Detection and Extraction Add-on to to blur only phone number in these images, but I do not know how to use it, that mean how to pass the params to blur exactly phone number, not others text in image.
Please support me that problem.
Thanks, Luan
0 -
Hi Luan,
The OCR Text Detection and Extraction Add-on can detect much of the text in an image, but I'm afraid there is no configuration option available to request only specific types of text (e.g. numbers) are detected.
This is also true of the Google Vision API which powers the Add-on, it is not possible to request that only phone numbers are detected; any text in the image will be detected and returned, along with the location of that text in the image.
As such, if you're using 'ocr_text' as the gravity option, it will apply to all text from the image.
What you could do if you need to blur only specific pieces of text like phone numbers, is to use our SDK or API to fetch the response from the Add-on, which includes all pieces of text in the image, and use your own code to decide which pieces should be blurred. Once you know which text you want to be blurred, you can use the coordinates returned by the Add-on to blur.For example, here's part of the 'ocr' response from the Add-On when I ran it on the image of the black car from the Add-on documentation:
[{"locale"=>"en", "description"=>"MV9570\n",
"boundingPoly"=>{"vertices"=>[{"x"=>171, "y"=>862}, {"x"=>416, "y"=>862}, {"x"=>416, "y"=>966}, {"x"=>171, "y"=>966}]}},
{"description"=>"MV9570", "boundingPoly"=>{"vertices"=>[{"x"=>182, "y"=>862}, {"x"=>416, "y"=>903}, {"x"=>405, "y"=>966}, {"x"=>171, "y"=>925}]}}],In this example, it's detected the license plate of the car, which is "MV9570", and returned the coordinates for a polygon which will cover the plate. If there were multiple pieces of text detected, you could decide in your code which is the best one to blur,
You can then use those coordinates to blur a rectangle around the region where the text was detected using our transformations: https://res.cloudinary.com/demo/image/upload/e_blur_region:800,x_171,y_862,w_245,h_105/black_car.jpg
Or highlight it: https://res.cloudinary.com/demo/image/upload/e_pixelate_region:40,x_171,y_862,w_245,h_105/black_car.jpg
Please take a look and let me know if that helps0
Post is closed for comments.
Comments
3 comments