0

I'm trying to create a GStreamer pipeline that can do image processing. Specifically, I'm doing image pre-processing to be used by machine learning networks. So this pipeline will do all the necessary pre-processing steps before it is fed to the neural network.
Right now, I'm trying to figure out if there are any GStreamer plugins that can simply do normalization.
GStreamer does allow programmers to create custom plugins for applications. This is one solution to this question, but I want to find out if there are any pre-existing solutions.

Anything might help!!! Thank you in advance.

I've looked into GStreamers list of plugins on their website but there are a lot and some descriptions aren't clear, to me, what they do or how to use them.
This page is a list of GStreamers plugins provided on their website.

This plugin sounded promising but isn't quite what I was looking for.

If anyone is curious, this is the normalization method that I want to replicate for my GStreamer pipeline.

def preprocess(img_data):
    mean_vec = np.array([0.485, 0.456, 0.406])
    stddev_vec = np.array([0.229, 0.224, 0.225])
    norm_img_data = np.zeros(img_data.shape).astype('float32')
    for i in range(img_data.shape[0]):  
         # for each pixel in each channel, divide the value by 255 to get value between [0, 1] and then normalize
        norm_img_data[i,:,:] = (img_data[i,:,:]/255 - mean_vec[i]) / stddev_vec[i]
    return norm_img_data
Mario
  • 1,631
  • 2
  • 21
  • 51

1 Answers1

1

When we use normalization on images for neural network inferences, we usually do:

${some video/x-raw stream} ! tensor_converter ! tensor_transform mode=arithmetic option=typecast:float32,add:-127.5,div:127.6 ! tensor_filter ${whatever neural network mode you want} ! .... 
MZX
  • 66
  • 3