<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Playing videos in JMP and evaluating video files in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Playing-videos-in-JMP-and-evaluating-video-files/m-p/478931#M72322</link>
    <description>&lt;P&gt;Dear Community,&lt;/P&gt;
&lt;P&gt;as videos are getting more and more important as "measurement data" to evaluate,&lt;/P&gt;
&lt;P&gt;I'm thinking of an application that combines a video of a process with other scalar (timeseries) data.&lt;/P&gt;
&lt;P&gt;For example, a JMP window that plays a video in the right half, and shows other time series data on the left half,&lt;/P&gt;
&lt;P&gt;indicating with a vertical line, where on the time scale the video shows the picture corresponding to some process or measurement data.&lt;/P&gt;
&lt;P&gt;For displaying time series data, JMP is the right choice, but whats about playing videos?&lt;/P&gt;
&lt;P&gt;Is it possible to play a video in JMP?&lt;/P&gt;
&lt;P&gt;Is it possible to read/analyze any video data (e.g. mp4, mpeg, ... files)?&lt;/P&gt;
&lt;P&gt;Any experience with tasks like this, any suggestion?&lt;/P&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;
&lt;P&gt;PS: using JMP16.1(Pro) on win10&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 11 Jun 2023 11:23:43 GMT</pubDate>
    <dc:creator>Georg</dc:creator>
    <dc:date>2023-06-11T11:23:43Z</dc:date>
    <item>
      <title>Playing videos in JMP and evaluating video files</title>
      <link>https://community.jmp.com/t5/Discussions/Playing-videos-in-JMP-and-evaluating-video-files/m-p/478931#M72322</link>
      <description>&lt;P&gt;Dear Community,&lt;/P&gt;
&lt;P&gt;as videos are getting more and more important as "measurement data" to evaluate,&lt;/P&gt;
&lt;P&gt;I'm thinking of an application that combines a video of a process with other scalar (timeseries) data.&lt;/P&gt;
&lt;P&gt;For example, a JMP window that plays a video in the right half, and shows other time series data on the left half,&lt;/P&gt;
&lt;P&gt;indicating with a vertical line, where on the time scale the video shows the picture corresponding to some process or measurement data.&lt;/P&gt;
&lt;P&gt;For displaying time series data, JMP is the right choice, but whats about playing videos?&lt;/P&gt;
&lt;P&gt;Is it possible to play a video in JMP?&lt;/P&gt;
&lt;P&gt;Is it possible to read/analyze any video data (e.g. mp4, mpeg, ... files)?&lt;/P&gt;
&lt;P&gt;Any experience with tasks like this, any suggestion?&lt;/P&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;
&lt;P&gt;PS: using JMP16.1(Pro) on win10&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 11:23:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Playing-videos-in-JMP-and-evaluating-video-files/m-p/478931#M72322</guid>
      <dc:creator>Georg</dc:creator>
      <dc:date>2023-06-11T11:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: Playing videos in JMP and evaluating video files</title>
      <link>https://community.jmp.com/t5/Discussions/Playing-videos-in-JMP-and-evaluating-video-files/m-p/479060#M72330</link>
      <description>&lt;P&gt;JMP handles JPG and PNG files without any external software. You can turn them into RGB matrices and do your own processing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To load a video, frame-by-frame, you could use OpenCV and Python, something like this&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JMP's Python interface using OpenCV to find a face." style="width: 213px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/41728iDC1EA78DD079AD09/image-size/large?v=v2&amp;amp;px=999" role="button" title="OpenCVFace.PNG" alt="JMP's Python interface using OpenCV to find a face." /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;JMP's Python interface using OpenCV to find a face.&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used &lt;EM&gt;&lt;STRONG&gt;python -m pip install opencv-python&lt;/STRONG&gt;&lt;/EM&gt; to install.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;pySetup =
"\[
# https://www.c-sharpcorner.com/article/detecting-faces-from-image-and-video-using-python/
# https://stackoverflow.com/questions/66942582/error-215assertion-failed-empty-in-function-cvcascadeclassifierdetec
# https://www.nps.gov/media/video/view.htm?id=C8B260AC-1DD8-B71B-0B793ECB496E64E5

import cv2  
      
# Load the cascade  
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')  
      
# To capture video from webcam.   
#cap = cv2.VideoCapture(0)  
cap = cv2.VideoCapture(file) 
strcap = str(cap)
#print(cap,flush=True)	
]\";

pyFinish = "\[
# Release the VideoCapture object  
cap.release()  	
]\";

pyGet =
"\[
# Read the frame  
_, img = cap.read()  
#print(img,flush=True)
# Convert to grayscale  
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)  
# Detect the faces  
faces = face_cascade.detectMultiScale(gray, 1.1, 4)  
# Draw the rectangle around each face  
for (x, y, w, h) in faces:  
    cv2.rectangle(img, (x, y), (x+w, y+h), (255, 0, 0), 2)  
  
# Display  
#cv2.imshow('Video', img)  
#print(type(img),img.shape)              
	
red = img[:,:,2]
green = img[:,:,1]
blue = img[:,:,0]

]\";

Python Init();
file = "https://www.nps.gov/nps-audiovideo/legacy/nature/C8B260AC-1DD8-B71B-0B793ECB496E64E5/nri-EOIntro3_240x134.mp4";
Python Execute( {file}, {strcap}, pySetup );
Show( strcap );

New Window( "x", bb = Border Box( Text Box( "" ) ), f=textbox() );
Wait( 1 );
frame=0;
While( 1,
    x = Log Capture( rc = Python Execute( {}, {red, green, blue, faces}, pyGet ) );
    If( Trim( x ) != "", Show( x ) );
    If( rc == -1, Break() ); // -1 is python fail on eof
    img = New Image( "rgb", {red / 255, green / 255, blue / 255} );
    (bb &amp;lt;&amp;lt; child) &amp;lt;&amp;lt; delete;
    bb &amp;lt;&amp;lt; append( img );
    frame += 1;
    f&amp;lt;&amp;lt;settext(evalinsert("frame ^frame^ faces(^char(faces)^)"));
    bb &amp;lt;&amp;lt; updatewindow;
);

Python Execute( {}, {}, pyFinish );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I borrowed the example from the link and modified it so JMP could drive it a picture at a time. It is very fast on this low res video, but most of the faces go unrecognized, probably because they are not facing straight at the camera. OpenCV has a lot of algorithms you'll find useful. I built &lt;A href="https://www.youtube.com/watch?v=nmgSWWY0G_Y" target="_self"&gt;this&lt;/A&gt; video a long time ago for motion detection.&lt;/P&gt;
&lt;P&gt;I did not try the webcam, but believe it should work.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 03:49:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Playing-videos-in-JMP-and-evaluating-video-files/m-p/479060#M72330</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2022-04-14T03:49:33Z</dc:date>
    </item>
    <item>
      <title>Re: Playing videos in JMP and evaluating video files</title>
      <link>https://community.jmp.com/t5/Discussions/Playing-videos-in-JMP-and-evaluating-video-files/m-p/480187#M72458</link>
      <description>&lt;P&gt;Thanks a lot, I think this will work, I need some time to test in detail.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 09:47:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Playing-videos-in-JMP-and-evaluating-video-files/m-p/480187#M72458</guid>
      <dc:creator>Georg</dc:creator>
      <dc:date>2022-04-19T09:47:19Z</dc:date>
    </item>
    <item>
      <title>Re: Playing videos in JMP and evaluating video files</title>
      <link>https://community.jmp.com/t5/Discussions/Playing-videos-in-JMP-and-evaluating-video-files/m-p/480202#M72466</link>
      <description>&lt;P&gt;Great! If you go the Python+OpenCV route, I'd like to see what you did.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(I'm a little embarrassed to not have handled the end of file exception better. The rc==-1 is detecting anything that goes wrong, which is good enough when everything goes well. You might need a try...except in the pyGet code to distinguish between the EOF exception you expect and other exceptions (like out of memory, ...) that might happen.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyone else, &lt;A href="https://github.com/opencv/opencv" target="_self"&gt;OpenCV&lt;/A&gt; is a computer vision library. Face detection is just one possibility.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 13:19:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Playing-videos-in-JMP-and-evaluating-video-files/m-p/480202#M72466</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2022-04-19T13:19:08Z</dc:date>
    </item>
  </channel>
</rss>

