Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C::Mat link back to Video Grabber #10

Open
awilkie1 opened this issue Mar 1, 2017 · 8 comments
Open

C::Mat link back to Video Grabber #10

awilkie1 opened this issue Mar 1, 2017 · 8 comments

Comments

@awilkie1
Copy link

awilkie1 commented Mar 1, 2017

Im trying to use the C::mat for as a source for a video grabber as I want to detect objects such as ArCuo. Can this be done on the pi using the native camera??

@orgicus
Copy link
Owner

orgicus commented Apr 2, 2018

If :

  • by C::mat you mean cv::Mat (OpenCV 2+ matrix image format)
  • by ArCuo you mean ArUco
  • by native camera you mean the PiCamera module (as opposed to a USB Camera)

Then the answer is yes :)

Have a look at example-ofxCvPiCamSimple
It should be possible to simply grab the frame from the ofxCvPiCam instance and pass it to ArUco:

//in update
cv::Mat frame = cam.grab();
if(!frame.empty()){
//pass the frame to ArUco here
}

@owenplanchart
Copy link

owenplanchart commented May 25, 2021

Hi,

by the same logic,

would it be possible to pass an ofxAruco object using ofxCvPiCam. How does one get the pixels from ofxCvPiCam?

@orgicus
Copy link
Owner

orgicus commented May 26, 2021

Hi @owenplanchart

It would be possible, but bare in my mind my basic addon fetches PiCamera data in cv::Mat format
while ofxAruco::detectBoards takes ofPixels & pixels as an argument. You can use ofxCv to easily wrap cv::Mat to ofPixels (for example using toOf(cv::Mat mat, ofPixels_<T>& pixels))

Hope this helps,
George

@owenplanchart
Copy link

Thank you,

I will give this a try

@owenplanchart
Copy link

Is this the right implementation?

void ofApp::update(){
    cv::Mat frame = cam.grab();
    ofPixels arPixels;
    toOf(frame, arPixels);
    if(!frame.empty()){
       aruco.detectBoards(arPixels);
    }
}

@orgicus
Copy link
Owner

orgicus commented May 27, 2021

@owenplanchart That looks good !
You should test it when you get a chance.
The other thing I'd recommend is maybe holding on two the frame and arPixels references and maybe doing the the empty() check before attempting to convert toOf(), something along these lines:

// in your ofApp.h for example
cv::Mat frame;
ofPixels arPixels;
// in your ofApp.cpp:
void ofApp::update(){
    frame = cam.grab();
    if(!frame.empty()){
       toOf(frame, arPixels);
       aruco.detectBoards(arPixels);
    }
}

@owenplanchart
Copy link

It's really strange because now I'm getting this error when I try to compile:

obj/linuxarmv6l/Release/src/ofApp.o: file not recognized: file truncated
collect2: error: ld returned 1 exit status
make[1]: *** [/home/pi/openFrameworks/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:405: bin/cvPiCamChand] Error 1
make[1]: Leaving directory '/home/pi/openFrameworks/apps/myApps/cvPiCamChand'
make: *** [/home/pi/openFrameworks/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:129: Release] Error 2

@owenplanchart
Copy link

@orgicus Not sure what happened there, so I re-downloaded the addon and wrote the sketch from scratch and managed to get the aruco markers working (yay!). This was on the RP3b (buster) with the Pi cam v2.1. Does this addon work with the pI4? Thanks so much for your work and help on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants