|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
MJPG Streamer input from opencv in C++
Hello!
I am setting up a vision co-processor with a raspberry pi 3 and I am having a trouble getting image data from opencv to mjpg-streamer. The reason I want to do this is so I can see the output of the opencv processing right on the smart dashboard. The specific issue is that there is no image showing up in the web server for mjpg-streamer. The page is continuously loading so I think its just not displaying the stream. I can even watch the avi file if I run omxplayer on the file. Here is my opencv code: Code:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <iostream>
#include <ntcore.h>
#include <cscore.h>
#include <networktables/NetworkTable.h>
void VisionThread() {
cv::VideoCapture vidCap(0);
cv::Mat frame;
cv::Mat output;
cv::namedWindow("Display Window", cv::WINDOW_AUTOSIZE);
if(!vidCap.isOpened()) {
std::cout << "Can't open video stream!" << "\n";
}
else {
vidCap.set(CV_CAP_PROP_FRAME_WIDTH,640);
vidCap.set(CV_CAP_PROP_FRAME_HEIGHT,480);
}
vidCap >> frame;
cv::VideoWriter outStream("output/out.avi", CV_FOURCC('M','J','P','G'), 30, frame.size(), true);
while(true) {
vidCap >> frame;
cv::circle(frame, cv::Point(320, 240), 5, cv::Scalar(255, 0, 0));
if(outStream.isOpened()) {
outStream.write(frame);
}
else {
std::cout<<"Can't write to file!" << "\n";
}
cv::imshow("Display Window", frame);
if(cv::waitKey(30) >= 0) break;
}
}
int main(int argc, const char** argv) {
VisionThread();
return 0;
}
Code:
mjpg_streamer -i "input_file.so -f /home/pi/vision_code/output" -o "output_http.so -w /usr/local/www" Thanks, Drew |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|