View Single Post
  #4   Spotlight this post!  
Unread 12-01-2017, 16:39
jreneew2's Avatar
jreneew2 jreneew2 is offline
Alumni of Team 2053 Tigertronics
AKA: Drew Williams
FRC #2053 (TigerTronics)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Vestal, NY
Posts: 212
jreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura about
Re: MJPG Streamer input from opencv in C++

Alright, I wrote up some new code and I am getting some linking errors around cscore. Here is my make file.

Here is the error Im getting
Code:
/tmp/ccVjljw2.o: In function `cs::VideoSource::VideoSource(cs::VideoSource const&)':
test.cpp:(.text._ZN2cs11VideoSourceC2ERKS0_[_ZN2cs11VideoSourceC5ERKS0_]+0x44): undefined reference to `cs::CopySource(int, int*)'
(And a bunch more like this)

Code:
# the compiler
CC = g++

#compiler flags:
CFLAGS = -std=c++0x `pkg-config --cflags --libs opencv` -I/home/pi/wpiutil/include -I/home/pi/ntcore/include -I/home/pi/cscore/include -L/home/pi/wpiutil/Linux/arm -L/home/pi/ntcore/arm/ntcore/build/libs/ntcore/static -L/home/pi/cscore/Linux/arm -lwpiutil -lntcore -lcscore  
TARGET = test

all: $(TARGET)

$(TARGET): $(TARGET).cpp
	$(CC) $(CFLAGS) -o $(TARGET) $(TARGET).cpp


clean:
	$(RM) (TARGET)
	$(RM) (CAMSERV)
Here is my code

Code:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <iostream>
#include <ntcore.h>
#include <networktables/NetworkTable.h>
#include <cscore.h>

void processImage() {
}

void VisionThread() {

	cs::UsbCamera camera = cs::UsbCamera("cam0", 0);
	cs::CvSink sink = cs::CvSink("sink");
	sink.SetSource(camera);
	cs::CvSource source = cs::CvSource("src", cs::VideoMode::PixelFormat::kMJPEG, 640, 480, 30);
	cs::MjpegServer mjpegServer = cs::MjpegServer("server", 1182);
	mjpegServer.SetSource(source);
	
	cv::Mat input;
	cv::Mat output;
	
	while(true) {
		sink.GrabFrame(input);
		cv::cvtColor(input, output, cv::COLOR_BGR2GRAY);
		source.PutFrame(output);
	}
}

int main(int argc, const char** argv) {
	
	VisionThread();
	
    return 0;
}
Thank you for the help!

- Drew
Reply With Quote