Applying filters to custom objects in an image

I would like to create an application that adds image filters (Snapchat-style) to photos of cats or chairs (just for the sake of this question). In order to do that properly, I thought of using Active Shape Modelling algorithms to have a model to apply the filters to. I trained an object detection model to identify those items in an image (yolov5), so I now have a bounding box around each item, but I still don't know its exact shape …
Category: Data Science

Cable angle measurement (rotation)

I need to detect the rotation of a cable (degree) in the x-axis with high precision [0.2 (or more) degree detection] from its original state. Detailed description: I have a cable that is set in its original state. The system has rotated the cable in the x-axis. I want to know the degree the cable has been rotated from its original state. Example: There're following images for a specific cable in different rotation (angle) [0, 0.4, 0.6, 0.8]: 1) 2) …
Category: Data Science

How to solve this ValueError: Dimensions must be equal

I'm trying to train an autoencoder model with colored image samples but I got this error ValueError: Dimensions must be equal, but are 476 and 480 for '{{node mean_squared_error/SquaredDifference}} = SquaredDifference[T=DT_FLOAT](model_4/conv2d_28/BiasAdd, IteratorGetNext:1)' with input shapes: [?,476,476,1], [?,480,480,3]. although i have checked the dimensions of the test and training sets all are (480,480,3) from matplotlib import image,pyplot import cv2 IMG_HEIGHT=480 IMG_WIDTH=480 def prepro_resize(input_img): oimg= cv2.imread( input_img, cv2.COLOR_BGR2RGB) return cv2.resize(oimg, (IMG_HEIGHT, IMG_WIDTH),interpolation = cv2.INTER_AREA) x_train_ = [(prepro_resize(x_train[i])).astype('float32')/255.0 for i in range(len(x_train))] x_test_ …
Category: Data Science

OpenCV warpAffine error during image augmentation using Albumentations

I have been trying to do image augmentation using a library called Albumentations. But I got some error from OpenCV while transforming the images. I ran the code below on Kaggle's notebook. The dataset is called "Intel image classification" on kaggle. It has 6 classes. Each image is 150 * 150 * 3. import numpy as np import tensorflow as tf import albumentations as a train_data = tf.keras.utils.image_dataset_from_directory( x_train_path, seed=123, image_size=(150, 150), batch_size=128) x_train_path = "../input/intel-image-classification/seg_train/seg_train" transforms = Compose([ a.Rotate(limit=40), …
Category: Data Science

How to solve MemoryError problem

I've created and normalized my colored image dataset of 3716 sample and size 493*491 as x_train, its type is list I'm tring to convert it into numpy array as follows from matplotlib import image import numpy as np import cv2 def prepro_resize(input_img): oimg=image.imread(input_img) return cv2.resize(oimg, (IMG_HEIGHT, IMG_WIDTH),interpolation = cv2.INTER_AREA) x_train_ = [(prepro_resize(x_train[i])).astype('float32')/255.0 for i in range(len(x_train))] x_train_ = np.array(x_train_) #L1 #print(x_train_.shape) but i get the following error when L1 runs MemoryError: Unable to allocate 10.1 GiB for an array with …
Category: Data Science

How can I detect partially obscured objects using Python?

I'm building a computer vision application using Python (OpenCV, keras-retinanet, tensorflow) which requires detecting an object and then counting how many objects are behind that front object. So, objects are often overlapping. For example: How many are in this queue? Here, the aim is to detect the person in the front (foreground) of the queue, and then detect the amount of people behind the front person, despite those behind being obscured. I have built an object recognition model using keras-retinanet …
Category: Data Science

White circles extraction from a little darker background

I'm trying to extract three white circles on the top left corner from the image below: I've tried to use: clone = img.copy() # Threshold grayscaled image to get binary image ret,gray_threshed = cv2.threshold(img,90,100,cv2.THRESH_TRUNC) cv2.imshow('gray', gray_threshed) # Find edges edge_detected_image = cv2.Canny(gray_threshed, 350, 100) # Find contours contours, _= cv2.findContours(edge_detected_image, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) contour_list = [] for contour in contours: contour_list.append(contour) # Draw contours cv2.drawContours(clone, contour_list, -1, (255,0,0), 2) #Resize image clone = cv2.resize(clone, (800, 800)) cv2.imshow('Objects Detected',clone) The result was: …
Category: Data Science

Read all files from all the folders

I am using Windows, Jupyter Notebook, OpenCV, Mediapipe, Tensorflow. Hello. I have a video Dataset with 100 action folders and each folder has 100 videos(.avi). Frames Per Second is 25. I want to read all the videos in all the action folders to collect the keypoints. I just want help with the code reading all the videos from all the folders using for loop or anything. And is there anyway to check if that code indeed read all the videos …
Category: Data Science

AttributeError: 'NoneType' object has no attribute 'landmark'

I am on windows, using jupyter notebook, Mediapipe:Holistic Solution, Python, tensorflow. I am using a Holistic solution and trying to get the left hand, right hand and pose landmarks. I am giving my webcam feed as input. When I run the code below, there are no errors and everything is good. After this, I was trying to check if I got the landmarks by using "results.left_hand_landmarks.landmark" and length of the landmarks using "len(results.left_hand_landmarks.landmark)" I am getting this "AttributeError: 'NoneType' object …
Category: Data Science

Detect blur image using ssdmobilenet and tensorflowlite

I have clear images of cards vs blurry images of card. My task is to capture photo when the image is not blurry, as you can see from the description I need this code to run in real time on android device. I have done some background reserarch on this topic 'Identify blurry image'. And found out few interesting solutions. Apply opencv transforms such as laplace or sobel filter. The blurry image will have less edges. And then using techniques …
Category: Data Science

Converting RGB values to contour values

I am using matplotlib to generate a filled contour plot, please consider the below example as a sample contour plot. I want to read off the contour values from such a filled contour plot using opencv's mouse interaction modules. For example, if the uses hovers the mouse over this contour image, it should dynamically display the contour values as the mouse moves over the image. I have the opencv part figured out, but I am struggling to link the RGB …
Category: Data Science

Identify visible stones in the image - Approach in OpenCV & Deeplearning

I have samples images of stones present in the images. I need to identify the visible stones only. The approach which I tried is threshold based filtering and detecting cv2.contours. Also, I am looking into ENet Architecture for semantic segmentation based deep learning approach. The samples images are below. Example image1: Example image2: The code which I tried for contour based detection is as below image = cv2.imread(os.path.join(img_path, img_name2)) # threshold based customization lower_bound = np.array([0, 0, 0]) upper_bound = …
Category: Data Science

When i'm training the pre-trained model on kaggle dataset, it is showing 79% accuracy. when i test on different dataset it shows 42% accuracy

This is the code i used to train the pre-trained model 'inception v3'. And can i know it is showing accuracy as 0.8717 but the val_accuracy as 0.7781. why there is a that much difference. Can anyone explain where it is training correctly or not. If not, can anyone suggest me what wrong is happening? Thanks in advance below is the Code: D:\NEW_DRD\Scripts\python.exe D:/NEW_DRD/own_model.py 2022-04-11 05:58:26.638080: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found 2022-04-11 05:58:26.639003: …
Category: Data Science

Detection of a specific shape in an image

I want to create an algorithm in order to detect the following shape (in the blue region) in videos or images: I have no dataset from the corresponding object so I thought that if I define it geometrically, I could use traditional image processing techniques with OpenCV (such as edge detection)to identify it. Is there more efficient or easier way ?
Category: Data Science

How to count no. of boxes using OpenCV?

I am trying to find no. of boxes available in the warehouse. I am using: Here is my code for the same. # Import libraries import cv2 import numpy as np import matplotlib.pyplot as plt image = cv2.imread('box.jpg') gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) plt.imshow(gray, cmap='gray') blur = cv2.GaussianBlur(gray, (11,11), 0) plt.imshow(blur, cmap='gray') canny = cv2.Canny(blur, 20, 50, 3) plt.imshow(canny, cmap='gray') # Here I am facing difficulty to draw exact lines for boxes as we can see small contours are also created …
Category: Data Science

Facial recognition on offline images

I want to do facial recognition on wide varieties of images captured at various ages of my family members. Below are some of the questions I have. If a person uses glasses of different types, do I need to feed images with each glasses type in the training dataset ? What if the eyes are not visible after wearing sunglasses. ? There are many pics which ranges from childhood to current age of approx 30. Do I need to train …
Category: Data Science

shapes recognition for shapes formed by dotted points

In the image, below right corner there is circle shape and triangle shape made with set of co-ordninates.I have searched extensively in the net for algorithm or approach to classify shape correctly .And yet came up with nothing.I need approach or directions to solve this problem.
Category: Data Science

Help me to identify the doors and windows from this image

I am struggling to mark windows and doors from this type of images. Actually, each images are in different style, and the color thermal maps also varies. There is no ground truth as well. Would you mind to suggest some directions or motivations to resolve this issue. I am not targetting deep learning based algorithms, basic opencv, python is appriciated. I am attaching a reference photo here.
Category: Data Science

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.