Dear Wiki user, You have subscribed to a wiki page or wiki category on "Tika Wiki" for change notification.
The "TikaAndVisionVideo" page has been changed by MadhavSharan: https://wiki.apache.org/tika/TikaAndVisionVideo?action=diff&rev1=1&rev2=2 = Tika and Computer Vision for Videos = - <<TableOfContents(4)>> + <<TableOfContents(5)>> This page describes how to make use of Object (Visual) Recognition capability of Apache Tika for videos. TIKA-2322 introduced a new parser to perform object recognition on videos. @@ -73, +73 @@ 4. Add an appname,Host IP 127.0.0.1 and set both ports to 8764. ===== b. Without Using docker ===== - If you chose to setup REST server without a docker container, you are free to manually install all the required tools specified in the [[ https://github.com/apache/tika/blob/master/tika-parsers/src/main/resources/org/apache/tika/parser/recognition/tf/InceptionVideoRestDockerfile | docker file]]. + If you chose to setup REST server without a docker container, you are free to manually install all the required tools specified in the [[ https://github.com/apache/tika/blob/master/tika-parsers/src/main/resources/org/apache/tika/parser/recognition/tf/InceptionVideoRestDockerfile | docker file]]. Note: docker file has setup instructions for Ubuntu, you will have to transform those commands for your environment. + + Below are the main requirements - + 1. [[ https://wiki.apache.org/tika/TikaAndVisionVideo#Installing_Tensorflow | Tensorflow]] + 2. [[ https://wiki.apache.org/tika/TikaAndVisionVideo#Installing_OpenCV | OpenCV with python and video support ]] + 3. Flask and requests - `pip install flask requests` + + {{{#!highlight bash python tika-parsers/src/main/resources/org/apache/tika/parser/recognition/tf/inceptionapi.py --port 8764 @@ -143, +150 @@ ==== Changing the default topN, API port or URL ==== - To change the defaults, update the parameters in config XML file accordingly + To change the defaults, update the parameters in config XML file accordingly. Below is a description of parameters accepted by Inception REST API, they can be passed through `apiUri` in config file. + + ||Param Name || Type || Description || Default Value || + ||<|4> mode ||<|4> string || Available Modes of frame extraction ||<|4> center || + || "center" - Just one frame in center || + || "interval" - Extracts frames after fixed interval || + || "fixed" - Extract fixed number of frames || + || frame-interval || int || Interval for frame extraction to be used with INTERVAL mode. If frame_interval=10 then every 10th frame will be extracted || 10 || + || num-frame || int || Number of frames to be extracted from video while using FIXED model. If num_frame=10 then 10 frames equally distant from each other will be extracted || 10 || + + If you want to run video recognition by extracting labels from every 100th image you can make an `apiUri` like `http://localhost:8764/inception/v4/classify/video?mode=interval&frame-interval=100` '''Here is an example scenario:''' @@ -182, +199 @@ ---- + === Manual Installation guide === + ==== Installing Tensorflow ==== + To install tensorflow, follow the instructions on [[https://www.tensorflow.org/install/|the official site here]] for your environment. + Unless you know what you are doing, you are recommended to follow pip installation. + Then clone the repository [[https://github.com/tensorflow/models|tensorflow/models]] or download the [[https://github.com/tensorflow/models/archive/master.zip|zip file]]. + {{{git clone https://github.com/tensorflow/models.git}}} + + Add 'models/slim' folder to the environment variable, PYTHONPATH. + + {{{$ export PYTHONPATH="$PYTHONPATH:/path/to/models/slim"}}} + + To test the readiness of your environment : + + {{{$ python -c 'import tensorflow, numpy, datasets; print("OK")'}}} + + If the above command prints the message "OK", then the requirements are satisfied. + + ==== Installing OpenCV ==== + OpenCV is a very popular computer vision library. We are using it to extract still images from video file. For this to work you need to install OpenCV with video support and python end point. Installation will vary from platform to platform so if you don't have enough experience with installing C packages it's a good idea to use docker build. + + - On Mac you can use homebrew to install OpenCV and make sure cv2.py is in your python path. + {{{#!bash + brew tap homebrew/science + brew install opencv + }}} + - [[https://github.com/apache/tika/blob/e141640891cd7adcfc1848b351c0db7eab00a2d2/tika-parsers/src/main/resources/org/apache/tika/parser/recognition/tf/InceptionVideoRestDockerfile#L30-L64|docker commands on ubuntu]] + + To verify if your setup is correct you can run below commands and they should print "SUCCESS" + {{{#!highlight bash + curl -Lo testVideoMp4.mp4 "https://github.com/apache/tika/blob/e141640891cd7adcfc1848b351c0db7eab00a2d2/tika-parsers/src/test/resources/test-documents/testVideoMp4.mp4?raw=true" + python -c "import cv2; cap = cv2.VideoCapture('testVideoMp4.mp4'); print 'SUCCESS' if cap.isOpened() else 'FAILURE'" + }}} + + ---- === Questions / Suggestions / Improvements / Feedback ? === 1. If it was useful, let us know on twitter by mentioning [[https://twitter.com/ApacheTika|@ApacheTika]]
