i.MX 8 opencv videocapture very slow (video file)

cancel
Showing results for 
Search instead for 
Did you mean: 

i.MX 8 opencv videocapture very slow (video file)

53 Views
alan13341313
Contributor I

alan13341313_0-1617868686876.png

For videocaptrue.read takes about 190ms per frame

Can someone tells me which part have I missed?

 

0 Kudos
5 Replies

10 Views
alan13341313
Contributor I

1. Build yocto and use.wic file inside yocto for SD card here's the steps

sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat cpio python python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm
mkdir ~/bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
export PATH=~/bin:$PATH
sudo apt-get install repo
git config --global user.name xxx
git config --global user.email xxx@gmail.com
git config --list
mkdir imx-yocto-bsp
cd imx-yocto-bsp
repo init -u https://source.codeaurora.org/external/imx/imx-manifest -b imx-linux-zeus -m imx-5.4.70-2.3.0.xml
repo sync
DISTRO=fsl-imx-xwayland MACHINE=imx8mpevk source imx-setup-release.sh -b build-yocto
bitbake imx-image-full

run this inside iMX8  (weston --tty=1 --device=/dev/fb0,/dev/fb2 --use-g2d=1 &)

2. Use aarch64-poky to build a simple opencv videoCapture read a frame a imshow for output

and scp into iMX then  ./test test.mp4

0 Kudos

50 Views
nxf65025
NXP Employee
NXP Employee

Can you share your steps?

0 Kudos

34 Views
alan13341313
Contributor I

1. Build yocto

sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat cpio python python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm
mkdir ~/bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
export PATH=~/bin:$PATH
sudo apt-get install repo
git config --global user.name davison
git config --global user.email davison12071994@gmail.com
git config --list
mkdir imx-yocto-bsp
cd imx-yocto-bsp
repo init -u https://source.codeaurora.org/external/imx/imx-manifest -b imx-linux-zeus -m imx-5.4.70-2.3.0.xml
repo sync
DISTRO=fsl-imx-xwayland MACHINE=imx8mpevk source imx-setup-release.sh -b build-yocto
bitbake imx-image-full

2. SD card

use .wic file in yocto for sd card

3. Run on iMX 8

run this in iMX8 (weston --tty=1 --device=/dev/fb0,/dev/fb2 --use-g2d=1 &)

Build a simple program by aarch64-poky and scp into iMX8 then ./test

 

 

Here's the code

#include "opencv2/opencv.hpp"
#include <iostream>

using namespace std;
using namespace cv;

int main(){

// Create a VideoCapture object
VideoCapture cap("test.mp4");

// Check if camera opened successfully
if(!cap.isOpened()){
cout << "Error opening video stream" << endl;
return -1;
}

while(1){

Mat frame;

// Capture frame-by-frame
cap >> frame;

// If the frame is empty, break immediately
if (frame.empty())
break;

// Display the resulting frame
imshow( "Frame", frame );

// Press ESC on keyboard to exit
char c = (char)waitKey(1);
if( c == 27 )
break;
}

// When everything done, release the video capture
cap.release();

// Closes all the frames
destroyAllWindows();
return 0;
}

0 Kudos

41 Views
alan13341313
Contributor I

Code looks like 95% like this

 

#include "opencv2/opencv.hpp"
#include <iostream>

using namespace std;
using namespace cv;

int main(){

  // Create a VideoCapture object
  VideoCapture cap("test.mp4"); 

  // Check if camera opened successfully
  if(!cap.isOpened()){
   	cout << "Error opening video stream" << endl;
        return -1;
  }
while(1){ Mat frame; // Capture frame-by-frame cap >> frame; // If the frame is empty, break immediately if (frame.empty()) break; // Display the resulting frame imshow( "Frame", frame ); // Press ESC on keyboard to exit char c = (char)waitKey(1); if( c == 27 ) break; } // When everything done, release the video capture cap.release(); // Closes all the frames destroyAllWindows(); return 0; }

 

0 Kudos

27 Views
nxf65025
NXP Employee
NXP Employee

OK,i will test it and give you feeback

0 Kudos