AI Logo Detection and Blurring with Grounding DINO

Brand logos are present almost everywhere. You can find them on T-shirts, bottles, shoes, bags, phones, and many other products. In some videos, these logos may need to be hidden before the content is shared. Doing this by hand can take a lot of time, especially when the logo keeps moving with the person or object.

This project builds a computer vision system to automate that task. It uses Grounding DINO to detect logos from a simple text prompt. Once a logo is detected, OpenCV is used to blur the detected region. The same pipeline can also be used on video, where each frame is checked and the detected logos are blurred.

The main goal is not to identify the brand. The system does not need to know if the logo belongs to Nike, Adidas, Puma, or another company. It only needs to find the logo and hide it. In this blog, we will look at how the system works, why Grounding DINO is useful for this task, how the blur is applied, and how the same idea can be used for video.

The Problem with Fixed Logo Detectors

A standard object detection model usually works with a fixed set of classes. For example, a model may be trained to detect people, cars, bottles, and other known objects. A logo detector can follow the same approach, but this creates a major problem.

There are thousands of brands. Each brand can also have more than one logo. Some logos are symbols, while others are written as text. If we train a model only on a small group of brands, it may fail when it sees a new logo.

Adding more brands also takes more work. We need images, annotations, training, testing, and model updates. This is not ideal when the goal is simply to hide logos.

Grounding DINO offers a different approach. It is an open-set object detection model. It can use language input to find objects based on category names or referring expressions. This allows us to describe what we want to find instead of using only fixed classes.

For this project, that means we can give the model a prompt such as “logo” and ask it to find possible logo regions.

How Grounding DINO Solves the Problem

The basic idea is simple. We give Grounding DINO an image and a text prompt. The model looks at both the image and the prompt. It then returns possible locations for the requested object.

For example, the prompt can be:

logo.

The model returns bounding boxes for the regions it thinks match the prompt. Each detection also has a confidence score.

The Hugging Face implementation provides GroundingDinoProcessor to prepare the image and text. It also provides post_process_grounded_object_detection() to convert the model output into usable bounding boxes, scores, and labels.

In this project, a confidence threshold of 0.30 was used during testing. This allows the model to keep some weaker detections that may still be useful for small logos.

Project Workflow

The complete system has four simple stages: input, detection, blur, and output. First, the system reads an image or video frame. The frame is converted into the required image format. Next, the image and the text prompt are sent to Grounding DINO.

  Project Workflow

The model predicts possible logo locations and returns bounding boxes. The detected box is then expanded slightly. This is useful because a very tight box may leave some pixels around the logo untouched.

Finally, OpenCV applies Gaussian blur to the selected area. The blurred region is placed back into the original image. Everything outside the detected region remains unchanged.

The full process can be shown as:

Image/Video → Grounding DINO → Logo Bounding Box → Gaussian Blur → Output

This makes the system simple to understand and easy to extend.

Detecting Logos in Images

The first step was to test the system on individual images. Image testing is useful because it lets us check the model before moving to video.

The image is loaded with PIL and passed to the Grounding DINO processor. The text prompt is set to “logo.” The model then runs inference and returns the detected boxes.

  Logo Detection

Each box contains four coordinates:

x1, y1, x2, y2

These coordinates define the top-left and bottom-right corners of the detected region. The region inside the box is then cropped from the image. OpenCV applies Gaussian blur to this crop. The blurred crop is placed back into the original image.

This approach does not need a separate segmentation model. Grounding DINO provides the location, and OpenCV handles the anonymization.

Why Use Bounding Boxes Instead of Segmentation?

A more advanced version could combine Grounding DINO with a segmentation model such as SAM. Grounding DINO would find the logo, and SAM could create a more exact mask around it.

That would produce a cleaner result. The blur would follow the exact shape of the logo instead of covering a rectangle. However, precise segmentation is not always needed for anonymization. The main goal is to make the logo unreadable.

Using the bounding box also keeps the project simple. There is no second vision model in the pipeline. We only need Grounding DINO and OpenCV. There is a trade-off. A bounding box can blur some of the surrounding shirt or product. A segmentation mask can be more precise. For a first version, the bounding box approach is faster to build and easier to maintain.

Improving the Blur Quality

The first blur test showed that a weak blur was not enough. Some logo details were still easy to see. The blur strength was then increased. The final test used:

cv2.GaussianBlur(roi, (151, 151), 80)

The large kernel creates a strong blur over the detected area. Padding is also added around the bounding box. This helps cover the edges of the logo.

There is a balance when choosing the padding. If the padding is too small, part of the logo may remain visible. If it is too large, more of the surrounding image will be blurred. For an anonymization system, covering a little more area is often better than leaving part of the logo visible.

Handling Video Inference

After the image pipeline worked, the next step was to process a complete video. A video contains many individual frames. OpenCV reads the video frame by frame. Each frame is sent to Grounding DINO. The model searches for logos, and the detected regions are blurred.

  Video Processing Pipeline

The processed frame is then written into a new video file. The basic workflow is:

Video → Frame → Grounding DINO → Logo Detection → Blur → Output Frame

This process continues until the video ends. Running Grounding DINO on every frame is simple, but it can be slow. A large detection model needs significant computing power, and video can contain thousands of frames.

The first tests were run on a CPU, but the inference time was too high. The project was then moved to a GPU environment. A platform such as Kaggle can provide a CUDA-enabled GPU, which makes this type of inference much more practical.

For a production system, the next step would be to add tracking. Grounding DINO could run every few frames, while a tracker follows the detected logo between those frames. This can reduce the number of model calls and make video processing faster.

Text-Based Logos Are a Challenge

One important limitation appeared during testing. Not every logo looks like a symbol. Some logos are graphic marks. Others are mostly text. For example, a brand name printed on a bottle may look like normal text to the model. This means the prompt “logo” may not detect every text-based brand mark.

One way to improve this is to use several prompts. Examples include:

“logo.”

“brand logo.”

“company logo.”

“text logo.”

“brand name.”

Grounding DINO supports multiple text concepts by separating them with periods. Another option is to add an OCR model. OCR can detect visible words, while Grounding DINO can detect graphic logos. Their results can then be combined before applying the blur. This would create a stronger hybrid system for both graphic and text-based logos.

Real-World Applications

A logo blurring system can be useful in many video workflows. A content team may need to hide brand logos before publishing footage. An automated first pass can reduce the amount of manual editing needed.

The system can also help with data preparation. Images and videos used in datasets may contain visible brand marks. A logo anonymization step can help prepare this content before it is shared or used for another task.

The same pipeline can also be adapted for other objects. Since Grounding DINO uses text prompts, the user can change the prompt based on the target. The system could be extended to detect signs, labels, product names, or other regions that need to be hidden.

Key Features of the System

Open-Vocabulary Detection

The system does not use a fixed list of brand classes. Grounding DINO uses language input to search for a visual concept. This makes a broad prompt such as “logo” possible.

Simple Blur Pipeline

The detected bounding boxes are passed to OpenCV. Gaussian blur is then applied to the selected regions. There is no need for a separate segmentation model in the current version.

Image and Video Support

The same detection and blur logic works on images and video frames. This makes it easy to test the model on a single image before running it on a full video.

GPU Support

The model can run on CUDA. This is important for video inference because the model may need to process many frames.

Conclusion

This project shows how an open-vocabulary model can be used for a practical computer vision task. Instead of training a separate detector for every brand, we use a text prompt to ask Grounding DINO to find logos.

The rest of the system is simple. Grounding DINO finds the logo region, and OpenCV hides it with a strong blur. The same process can be applied to video frames to create an automated logo blurring system.

The current version still has some limits. Small logos, unusual designs, low-quality footage, and text-only brand names may be missed. Better prompts, OCR, tracking, and segmentation can improve the next version.

Still, the main idea is useful. We can use language to tell a vision model what to look for, then use image processing to hide the result. This creates a simple base for a more advanced AI-powered logo anonymization system.

FAQs

What is Grounding DINO used for in logo detection?

Grounding DINO is used to detect logos in images and videos using text prompts such as “logo” or “brand logo,” without training a separate model for every brand.

Can Grounding DINO detect logos in videos?

Yes. Grounding DINO can process video frames one by one to detect logos, after which the detected regions can be blurred using OpenCV.

Can this project blur text-based brand logos?

Text-based logos can be harder to detect with a simple “logo” prompt. Using additional prompts such as “brand name” or “text logo,” or adding OCR, can improve detection.