'how to save or convert holoviews object to image or video
I am trying to detect an image through a detector and want to save it to video or image, but I could not find anything with holoviews DynamicMap to save to image or to video. Please help
fname=r'D:\tiff_data\output_0302.tif'
#fname=r'D:\cite-on-main\poly_wet (1209).tif'
save='outputs/demo'
os.makedirs(save,exist_ok=True)
im=Image.open(fname)
import cv2
img = cv2.imread(fname)
median=np.median(img,axis=2)
upscaling=0.9
detector=Detector('./weights/', gpu='0', init_shape=img.shape[:2], init_upscaling=upscaling)
def explore(Score, Upscaling):
width = median.shape[1]
height = median.shape[0]
detections=detector.detect(median,Score,Upscaling)
aaa = hv.Image((np.arange(width),np.arange(height),median)).opts(title='',invert_yaxis=True, cmap='gray',width=median.shape[1]*scale, height=median.shape[0]*scale,)*hv.Path([hv.Bounds(tuple(r)) for r in detections[:,:4]]).opts(color='lime')
return aaa
dmap=hv.DynamicMap(explore, kdims=['Upscaling','Score'])
dmap.redim.values( Score=np.arange(0.1,1,0.05), Upscaling=np.arange(1,3,0.1))
Solution 1:[1]
You can convert a DynamicMap to a HoloMap (http://holoviews.org/user_guide/Live_Data.html#converting-from-dynamicmap-to-holomap) and export a HoloMap to a png or gif or mp4 (https://holoviews.org/user_guide/Exporting_and_Archiving.html). You may need to install some extra dependencies depending on your backend, but the error messages should guide you to what you need. Exporting Matplotlib output is generally easier and faster than Bokeh output, but both should work.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | James A. Bednar |
