Software Archive
Read-only legacy content
17061 Discussions

OpenCV and Galileo Gen1

Anonymous
Not applicable
3,923 Views

I have read many questions over the last few months but I cannot find a tutorial for what I need and I am pretty lost to be honest. Can anyone help out in guiding me to complete my goal for one of my systems. 

I have a system built on an Intel Galileo Gen 1 and I want to be able to provide a feature that from the GUI I have built for the system, users can view a stream from the webcam attached to the board to see realtime what is going on in the location surrounding the unit. I have searched and searched, seen all of the videos on google and still can't find a kind of step by step from installing opencv to getting it running so I can connect to the webcam that is attached to the board.

If anyone can help will be appreciated.

0 Kudos
1 Solution
Anonymous
Not applicable
3,911 Views

Hi matthias-hahn (Intel) / Stewart Christie (Intel) 

BOOM :D Ok got it taking a photo. 

#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main()
{
VideoCapture cap(-1);
//check if the file was opened properly
if(!cap.isOpened())
{
cout << "Webcam could not be opened succesfully" << endl;
exit(-1);
}
else
{
cout << "p n" << endl;
}
int w = 960;
int h = 544;
cap.set(CV_CAP_PROP_FRAME_WIDTH, w);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, h);
Mat frame;
cap >>frame;
imwrite("opencv.jpg", frame);
cap.release();
return 0;
}

 Stewart Christie (Intel) Thank you the ebook got me here. So my next stage is to make the node js server trigger this file and save an image that can be accessed via the node server is this possible ? Once I have that sorted I will look into the video streaming but this is definitely a move forward thanks for help so far :D

 

 

View solution in original post

0 Kudos
31 Replies
Anonymous
Not applicable
938 Views

Having had any experience with circular buffer I don't think. Could you elaborate please.

This is the error log from npm for opencv-node


root@quark00a8ee:~#  npm install opencv
npm http GET https://registry.npmjs.org/opencv
npm http 304 https://registry.npmjs.org/opencv
npm http GET https://registry.npmjs.org/buffers
npm http GET https://registry.npmjs.org/node-pre-gyp
npm http GET https://registry.npmjs.org/nan
npm http 304 https://registry.npmjs.org/nan
npm http 304 https://registry.npmjs.org/node-pre-gyp
npm http 304 https://registry.npmjs.org/buffers

> opencv@3.0.0 install /home/root/node_modules/opencv
> node-pre-gyp install --fallback-to-build

node-pre-gyp http GET https: // node-opencv.s3.amazonaws.com/opencv/v3.0.0/Release/node-v11-linux-ia32.tar.gz
node-pre-gyp http 403 https: // node-opencv.s3.amazonaws.com/opencv/v3.0.0/Release/node-v11-linux-ia32.tar.gz
node-pre-gyp http 403 status code downloading tarball (falling back to source compile with node-gyp)
make: Entering directory '/home/root/node_modules/opencv/build'
  CXX(target) Release/obj.target/opencv/src/init.o
  CXX(target) Release/obj.target/opencv/src/Matrix.o
  CXX(target) Release/obj.target/opencv/src/OpenCV.o
  CXX(target) Release/obj.target/opencv/src/CascadeClassifierWrap.o
  CXX(target) Release/obj.target/opencv/src/Contours.o
  CXX(target) Release/obj.target/opencv/src/Point.o
  CXX(target) Release/obj.target/opencv/src/VideoCaptureWrap.o
  CXX(target) Release/obj.target/opencv/src/CamShift.o
  CXX(target) Release/obj.target/opencv/src/HighGUI.o
  CXX(target) Release/obj.target/opencv/src/FaceRecognizer.o
  CXX(target) Release/obj.target/opencv/src/BackgroundSubtractor.o
  CXX(target) Release/obj.target/opencv/src/Constants.o
  CXX(target) Release/obj.target/opencv/src/Calib3D.o
  CXX(target) Release/obj.target/opencv/src/ImgProc.o
  SOLINK_MODULE(target) Release/obj.target/opencv.node
/usr/lib/gcc/i586-poky-linux/4.8.2/../../../../i586-poky-linux/bin/ld: cannot find -lopencv_ts
collect2: error: ld returned 1 exit status
opencv.target.mk:148: recipe for target 'Release/obj.target/opencv.node' failed
make: *** [Release/obj.target/opencv.node] Error 1
make: Leaving directory '/home/root/node_modules/opencv/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:807:12)
gyp ERR! System Linux 3.8.7-yocto-standard
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--name=opencv" "--configuration=Release" "--module_name=opencv" "--version=3.0.0" "--major=3" "--runtime=node" "--node_abi=node-v11" "--platform=linux" "--target_platform=linux" "--arch=ia32" "--target_arch=ia32" "--module_main=./lib/opencv" "--host=https://node-opencv.s3.amazonaws.com/" "--module_path=/home/root/node_modules/opencv/build/opencv/v3.0.0/Release/node-v11-linux-ia32" "--module=/home/root/node_modules/opencv/build/opencv/v3.0.0/Release/node-v11-linux-ia32/opencv.node" "--remote_path=./opencv/v3.0.0/Release/" "--package_name=node-v11-linux-ia32.tar.gz" "--staged_tarball=build/stage/opencv/v3.0.0/Release/node-v11-linux-ia32.tar.gz" "--hosted_path=https://node-opencv.s3.amazonaws.com/opencv/v3.0.0/Release/" "--hosted_tarball=https: // node-opencv.s3.amazonaws.com/opencv/v3.0.0/Release/node-v11-linux-ia32.tar.gz"
gyp ERR! cwd /home/root/node_modules/opencv
gyp ERR! node -v v0.10.28
gyp ERR! node-gyp -v v0.13.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js rebuild --name=opencv --configuration=Release --module_name=opencv --version=3.0.0 --major=3 --runtime=node --node_abi=node-v11 --platform=linux --target_platform=linux --arch=ia32 --target_arch=ia32 --module_main=./lib/opencv --host=https://node-opencv.s3.amazonaws.com/ --module_path=/home/root/node_modules/opencv/build/opencv/v3.0.0/Release/node-v11-linux-ia32 --module=/home/root/node_modules/opencv/build/opencv/v3.0.0/Release/node-v11-linux-ia32/opencv.node --remote_path=./opencv/v3.0.0/Release/ --package_name=node-v11-linux-ia32.tar.gz --staged_tarball=build/stage/opencv/v3.0.0/Release/node-v11-linux-ia32.tar.gz --hosted_path=https://node-opencv.s3.amazonaws.com/opencv/v3.0.0/Release/ --hosted_tarball=https://node-opencv.s3.amazonaws.com/opencv/v3.0.0/Release/node-v11-linux-ia32.tar.gz' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/root/node_modules/opencv/node_modules/node-pre-gyp/lib/util/compile.js:76:29)
node-pre-gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
node-pre-gyp ERR! stack     at maybeClose (child_process.js:753:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:820:5)
node-pre-gyp ERR! System Linux 3.8.7-yocto-standard
node-pre-gyp ERR! command "node" "/home/root/node_modules/opencv/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/root/node_modules/opencv
node-pre-gyp ERR! node -v v0.10.28
node-pre-gyp ERR! node-pre-gyp -v v0.5.31
node-pre-gyp ERR! not ok
Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js rebuild --name=opencv --configuration=Release --module_name=opencv --version=3.0.0 --major=3 --runtime=node --node_abi=node-v11 --platform=linux --target_platform=linux --arch=ia32 --target_arch=ia32 --module_main=./lib/opencv --host=https://node-opencv.s3.amazonaws.com/ --module_path=/home/root/node_modules/opencv/build/opencv/v3.0.0/Release/node-v11-linux-ia32 --module=/home/root/node_modules/opencv/build/opencv/v3.0.0/Release/node-v11-linux-ia32/opencv.node --remote_path=./opencv/v3.0.0/Release/ --package_name=node-v11-linux-ia32.tar.gz --staged_tarball=build/stage/opencv/v3.0.0/Release/node-v11-linux-ia32.tar.gz --hosted_path=https://node-opencv.s3.amazonaws.com/opencv/v3.0.0/Release/ --hosted_tarball=https://node-opencv.s3.amazonaws.com/opencv/v3.0.0/Release/node-v11-linux-ia32.tar.gz' (1)
npm ERR! opencv@3.0.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the opencv@3.0.0 install script.
npm ERR! This is most likely a problem with the opencv package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get their info via:
npm ERR!     npm owner ls opencv
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.8.7-yocto-standard
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "opencv"
npm ERR! cwd /home/root
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/root/npm-debug.log
npm ERR! not ok code 0

0 Kudos
Anonymous
Not applicable
938 Views
root@quark00a8ee:~#  npm install opencv
npm http GET https://registry.npmjs.org/opencv
npm http 304 https://registry.npmjs.org/opencv
npm http GET https://registry.npmjs.org/buffers
npm http GET https://registry.npmjs.org/node-pre-gyp
npm http GET https://registry.npmjs.org/nan
npm http 304 https://registry.npmjs.org/nan
npm http 304 https://registry.npmjs.org/node-pre-gyp
npm http 304 https://registry.npmjs.org/buffers

> opencv@3.0.0 install /home/root/node_modules/opencv
> node-pre-gyp install --fallback-to-build

node-pre-gyp http GET https://node-opencv.s3.amazonaws.com/opencv/v3.0.0/Release/node-v11-linux-ia32.tar.gz
node-pre-gyp http 403 https://node-opencv.s3.amazonaws.com/opencv/v3.0.0/Release/node-v11-linux-ia32.tar.gz
node-pre-gyp http 403 status code downloading tarball (falling back to source compile with node-gyp)
make: Entering directory '/home/root/node_modules/opencv/build'
  CXX(target) Release/obj.target/opencv/src/init.o
  CXX(target) Release/obj.target/opencv/src/Matrix.o
  CXX(target) Release/obj.target/opencv/src/OpenCV.o
  CXX(target) Release/obj.target/opencv/src/CascadeClassifierWrap.o
  CXX(target) Release/obj.target/opencv/src/Contours.o
  CXX(target) Release/obj.target/opencv/src/Point.o
  CXX(target) Release/obj.target/opencv/src/VideoCaptureWrap.o
  CXX(target) Release/obj.target/opencv/src/CamShift.o
  CXX(target) Release/obj.target/opencv/src/HighGUI.o
  CXX(target) Release/obj.target/opencv/src/FaceRecognizer.o
  CXX(target) Release/obj.target/opencv/src/BackgroundSubtractor.o
  CXX(target) Release/obj.target/opencv/src/Constants.o
  CXX(target) Release/obj.target/opencv/src/Calib3D.o
  CXX(target) Release/obj.target/opencv/src/ImgProc.o
  SOLINK_MODULE(target) Release/obj.target/opencv.node
/usr/lib/gcc/i586-poky-linux/4.8.2/../../../../i586-poky-linux/bin/ld: cannot find -lopencv_ts
collect2: error: ld returned 1 exit status
opencv.target.mk:148: recipe for target 'Release/obj.target/opencv.node' failed
make: *** [Release/obj.target/opencv.node] Error 1
make: Leaving directory '/home/root/node_modules/opencv/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:807:12)
gyp ERR! System Linux 3.8.7-yocto-standard
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--name=opencv" "--configuration=Release" "--module_name=opencv" "--version=3.0.0" "--major=3" "--runtime=node" "--node_abi=node-v11" "--platform=linux" "--target_platform=linux" "--arch=ia32" "--target_arch=ia32" "--module_main=./lib/opencv" "--host=https://node-opencv.s3.amazonaws.com/" "--module_path=/home/root/node_modules/opencv/build/opencv/v3.0.0/Release/node-v11-linux-ia32" "--module=/home/root/node_modules/opencv/build/opencv/v3.0.0/Release/node-v11-linux-ia32/opencv.node" "--remote_path=./opencv/v3.0.0/Release/" "--package_name=node-v11-linux-ia32.tar.gz" "--staged_tarball=build/stage/opencv/v3.0.0/Release/node-v11-linux-ia32.tar.gz" "--hosted_path=https://node-opencv.s3.amazonaws.com/opencv/v3.0.0/Release/" "--hosted_tarball=https://node-opencv.s3.amazonaws.com/opencv/v3.0.0/Release/node-v11-linux-ia32.tar.gz"
gyp ERR! cwd /home/root/node_modules/opencv
gyp ERR! node -v v0.10.28
gyp ERR! node-gyp -v v0.13.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js rebuild --name=opencv --configuration=Release --module_name=opencv --version=3.0.0 --major=3 --runtime=node --node_abi=node-v11 --platform=linux --target_platform=linux --arch=ia32 --target_arch=ia32 --module_main=./lib/opencv --host=https://node-opencv.s3.amazonaws.com/ --module_path=/home/root/node_modules/opencv/build/opencv/v3.0.0/Release/node-v11-linux-ia32 --module=/home/root/node_modules/opencv/build/opencv/v3.0.0/Release/node-v11-linux-ia32/opencv.node --remote_path=./opencv/v3.0.0/Release/ --package_name=node-v11-linux-ia32.tar.gz --staged_tarball=build/stage/opencv/v3.0.0/Release/node-v11-linux-ia32.tar.gz --hosted_path=https://node-opencv.s3.amazonaws.com/opencv/v3.0.0/Release/ --hosted_tarball=https://node-opencv.s3.amazonaws.com/opencv/v3.0.0/Release/node-v11-linux-ia32.tar.gz' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/root/node_modules/opencv/node_modules/node-pre-gyp/lib/util/compile.js:76:29)
node-pre-gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
node-pre-gyp ERR! stack     at maybeClose (child_process.js:753:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:820:5)
node-pre-gyp ERR! System Linux 3.8.7-yocto-standard
node-pre-gyp ERR! command "node" "/home/root/node_modules/opencv/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/root/node_modules/opencv
node-pre-gyp ERR! node -v v0.10.28
node-pre-gyp ERR! node-pre-gyp -v v0.5.31
node-pre-gyp ERR! not ok
Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js rebuild --name=opencv --configuration=Release --module_name=opencv --version=3.0.0 --major=3 --runtime=node --node_abi=node-v11 --platform=linux --target_platform=linux --arch=ia32 --target_arch=ia32 --module_main=./lib/opencv --host=https://node-opencv.s3.amazonaws.com/ --module_path=/home/root/node_modules/opencv/build/opencv/v3.0.0/Release/node-v11-linux-ia32 --module=/home/root/node_modules/opencv/build/opencv/v3.0.0/Release/node-v11-linux-ia32/opencv.node --remote_path=./opencv/v3.0.0/Release/ --package_name=node-v11-linux-ia32.tar.gz --staged_tarball=build/stage/opencv/v3.0.0/Release/node-v11-linux-ia32.tar.gz --hosted_path=https://node-opencv.s3.amazonaws.com/opencv/v3.0.0/Release/ --hosted_tarball=https://node-opencv.s3.amazonaws.com/opencv/v3.0.0/Release/node-v11-linux-ia32.tar.gz' (1)
npm ERR! opencv@3.0.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the opencv@3.0.0 install script.
npm ERR! This is most likely a problem with the opencv package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get their info via:
npm ERR!     npm owner ls opencv
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.8.7-yocto-standard
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "opencv"
npm ERR! cwd /home/root
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/root/npm-debug.log
npm ERR! not ok code 0

Not sure about circular buffer, never heard of it can you elaborate please.

0 Kudos
Anonymous
Not applicable
938 Views

Sent you message as my posts need to be reviewed for some reason, maybe it was the error log.

Can you elaborate on the circular buffer ?

0 Kudos
Anonymous
Not applicable
938 Views

Ok I have made a quick fix for now so that I can just move on for now to other parts and finish this version to a certain degree. Here is what I have done:

I have made the image just overwrite each time it is created, my external GUI on TechBubble simply calls that image via ajax refreshing every two seconds and I get as close to a video as possible at this moment but fairly happy with it so far, works pretty good.

What I have to do now is get the C++ project working on startup of the board, any ideas on this please. 

0 Kudos
Anonymous
Not applicable
938 Views

I did just get this error though after a while of it running.

Unable to stop the stream.: No such device
Unable to stop the stream.: Bad file descriptor
HIGHGUI ERROR: V4L/V4L2: Could not obtain specifics of capture window.

Unable to stop the stream.: Bad file descriptor
VIDIOC_QBUF: Bad file descriptor
Writing Image
Image Written 
1429797957
Segmentation fault
logout

0 Kudos
Matthias_H_Intel
Employee
938 Views

AdamMiltonBarker wrote:

What I have to do now is get the C++ project working on startup of the board, any ideas on this please. 

systemd service?

0 Kudos
Anonymous
Not applicable
938 Views

OK thanks will look into that, the way I am showing the "video" I described is not very good it is slow and sometimes loads a blank image going to look at the video streaming way to have an iframe on the external GUI to view the realtime from what I am reading this process is quite similar but not been able to get it working, does any have any new documentation I may of missed ?

0 Kudos
Anonymous
Not applicable
938 Views

matthias-hahn (Intel) did you receive the message about the error installing opencv-nodejs ?

0 Kudos
Anonymous
Not applicable
938 Views

I am now here:

#include <opencv2/opencv.hpp>
#include <iostream>
#include <ctime>
using namespace cv;
using namespace std;
int main()
{
	VideoCapture cap(-1);
	if(!cap.isOpened()){
		cout << "Webcam could not be opened successfully" << endl;
		exit(-1);
	} else {
		cout << "Webcam opened successfully" << endl;
	}
   double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH);
   double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT);
   cout << "Frame Size = " << dWidth << "x" << dHeight << endl;
   Size frameSize(static_cast<int>(dWidth), static_cast<int>(dHeight));
   VideoWriter oVideoWriter ("video.mpeg" ,CV_FOURCC('M','J','P','G'), 1 ,frameSize, 0);
   if ( !oVideoWriter.isOpened() ){
		cout << "ERROR: Failed to write the video" << endl;
		return -1;
   }
	for(;;){

		Mat frame;
		bool bSuccess = cap.read(frame);

		if (!bSuccess){
			 cout << "ERROR: Cannot read a frame from video file" << endl;
			 break;
		}

		oVideoWriter.write(frame);

		if (waitKey(10) == 27){
			cout << "esc key is pressed by user" << endl;
			break;
	   }
    }

	cap.release();
	return 0;
}

But when it gets to Videowriter it fails ERROR: Failed to write the video, is the write way I am to be going to stream a video and any ideas on how to get started fixing this ?

0 Kudos
Anonymous
Not applicable
938 Views

Totally lost on this one guys, been searching all day and trying different codes but cannot get the video to write, I know that the folder is writable as the images write there fine, I know that the camera is working well on the board as it captures images repeatedly in my last script and stores them which my GUI can retrieve and display back. 

I have tried changing this line with all of the available codecs I have found but it is still failing to write a video any ideas please ?

   VideoWriter oVideoWriter ("video.avi",CV_FOURCC('M','J','P','G'), 30 ,frameSize);

I believe it is to do with codecs on the board, firing ffmpeg -codecs returns  ffmpeg: command not found I have again searched all over to try find out how to install ffmpeg but found nothing for intel galileo

 

0 Kudos
Anonymous
Not applicable
938 Views

I have got to a point where I am fairly happy. This is a quick demo, thanks to the people that helped me suss out the issues, here is the end result:

https://www.youtube.com/watch?v=Wva9MvEg_LA

0 Kudos
Reply