Hi,
I would extract from the mask created by the network fcn-resnet18-mhp-512x320
, but no extraction has done. To do that, I write in my segNet.py file this following code. I precise I don’t have add the part concerning the opt arguments. I speak about the 4 last lines. If you have an idea why my result is the same of my original mask on output2? Thanks for your help.
import jetson.inference
import jetson.utils
import argparse
import sys
from segnet_utils import *
import cv2
import numpy as np
#... opt arguments
net = jetson.inference.segNet(opt.network, sys.argv)
net.SetOverlayAlpha(opt.alpha)
buffers = segmentationBuffers(net, opt)
input = jetson.utils.videoSource(opt.input_URI, argv=sys.argv)
output = jetson.utils.videoOutput(opt.output_URI, argv=sys.argv+is_headless)
output2= jetson.utils.videoOutput(opt.output_URI, argv=sys.argv+is_headless)
while True: #{
img_input = input.Capture()
buffers.Alloc(img_input.shape, img_input.format)
net.Process(img_input, ignore_class=opt.ignore_class)
if buffers.overlay:
net.Overlay(buffers.overlay, filter_mode=opt.filter_mode)
if buffers.mask:
net.Mask(buffers.mask, filter_mode=opt.filter_mode)
if buffers.composite:
jetson.utils.cudaOverlay(buffers.overlay, buffers.composite, 0, 0)
jetson.utils.cudaOverlay(buffers.mask, buffers.composite, buffers.overlay.width, 0)
output.Render(buffers.output)
output.SetStatus("{:s} | Network {:.0f} FPS".format(opt.network, net.GetNetworkFPS()))
jetson.utils.cudaDeviceSynchronize()
net.PrintProfilerTimes()
if opt.stats:
buffers.ComputeStats()
if not input.IsStreaming() or not output.IsStreaming():
break
is_the_hand=(buffers.mask ==(255,165,0)) #color of hand
#binary mask
buffers.mask[is_the_hand]=(255,255,255) #white for hand
buffers.mask[np.logical_not(is_the_hand)]=(0,0,0) #black for no hand
output2.Render(buffers.mask)
#} end while