Ask Your Question
0

Accessing a camera-linked X1 mini PCIE camera

asked 2019-10-01 01:25:13 -0500

Vizier87 gravatar image

updated 2019-10-01 01:26:40 -0500

Hi guys,

I'm currently using a specialized camera (OWL 320 Raptor Photonics). I'm attempting at connecting it with OpenCV, but I guess the protocol is not as straightforward as it could be with a simple USB-connected type.

I've tried it by changing the values from 0-2 in the following line:

VideoCapture capture(0);

And it doesn't detect the feed. It works fine with my old webcam, for the record.

The camera is run by a specialized software called XCAP. This software runs well, no issues, and I get the feed just fine.

I'm using OpenCV 4.1.1 with Visual Studio C++ 2019.

Is it still possible though?

Thanks. Vizier87

PS: The complete code is attached here: https://www.mediafire.com/file/fyl3b8...

Sorry I didn't want to clutter this query since it was quite long.

edit retag flag offensive close merge delete

Comments

does your XCAP software come with an SDK of any kind ?

and I get the feed just fine.

what does it mean ? involving code ?

berak gravatar imageberak ( 2019-10-01 01:30:07 -0500 )edit

Good question. I've sent an email to the guys in the company and see if it comes with something.

Vizier87 gravatar imageVizier87 ( 2019-10-01 02:06:48 -0500 )edit
1

and I get the feed just fine.

what does it mean ? involving code ?

I meant the feed was fine using the XCAP software. Not by using OpenCV.

Vizier87 gravatar imageVizier87 ( 2019-10-01 02:09:01 -0500 )edit

once you have a pointer to the pixels, you can easily construct a cv::Mat from it (sidestepping the VideoCapture class)

berak gravatar imageberak ( 2019-10-01 02:11:53 -0500 )edit

And this can only be done if I have the SDK/API? Or is there a workaround?

Honestly I prefer workarounds.. VS2019 offers that flexibility.

Vizier87 gravatar imageVizier87 ( 2019-10-01 02:13:33 -0500 )edit
1

oh, i just looked at the bottom of this and it seems, you have to pay hefty for the resp. SDK. ;(

berak gravatar imageberak ( 2019-10-01 02:18:02 -0500 )edit

Oh my.. Do you think there's another way?

Anyway, does the SDK enable OpenCV access to the frames grabbed?

Vizier87 gravatar imageVizier87 ( 2019-10-01 02:37:07 -0500 )edit
1

does the SDK enable OpenCV access to the frames grabbed?

i guess, it has some method to grab a frame, and retrieve the pixels. knowing W & H you can construct a cv::Mat from the buffer, and continue without using cv::VideoCapture

Do you think there's another way?

well, they have to access the cam, too ;) their software seems java based, and can be decompiled. their C based, low level dlls can be dumped too.

if you're a hacker, there's for sure a way.

berak gravatar imageberak ( 2019-10-01 02:52:04 -0500 )edit

I guess I'll have to record the video and then perform some dumb processing later... Sigh.

I'll see if I can still access it though.

Thanks Berak. Much appreciated.

Vizier87 gravatar imageVizier87 ( 2019-10-01 02:59:21 -0500 )edit
1

Hi berak, I think I might have a lead: http://www.epixinc.com/manuals/pixci_...

It has something called XCLIB.

I'll try my best to understanding this section, but I'd like your opinion first: will this guide help in my endeavor?

Thanks.

Vizier87 gravatar imageVizier87 ( 2019-10-03 02:51:21 -0500 )edit

2 answers

Sort by ยป oldest newest most voted
1

answered 2019-10-08 00:55:16 -0500

berak gravatar image

updated 2019-10-08 00:57:28 -0500

nice, that you found that !

i think, you should read the pixels directly into a cv::Mat (and skip that buf variable):

Mat getPixels() {

    // allocate 8bit pixel data, 1 or 3 channels:
    Mat img( pxd_imageYdim(), pxd_imageXdim(), pxd_imageCdim() == 1 ? CV_8UC1 : CV_8UC3);

    pxd_readuchar(0x1, 1, 0, 0, -1, -1, (void*)img.data,  // <-- here we pass allocated mem.
            pxd_imageXdim() * pxd_imageYdim() * pxd_imageCdim(),
            pxd_imageCdim() == 1 ? "Grey" : "RGB");

    return img;

}

then, you might have to convert RGB to BGR (or not, just be aware...)

edit flag offensive delete link more

Comments

1

Thanks berak. I feel I'm getting much closer now. Right now I'm just testing this line of the code:

Mat img(pxd_imageYdim(), pxd_imageXdim(), pxd_imageCdim() == 1 ? CV_8UC1 : CV_8UC3);

The error generated was:

Unhandled exception at 0x00007FFC05C5A839 in EPIX + OpenCV.exe: Microsoft C++ exception: cv::Exception at memory location 0x00000073CF9CF160. occurred

And the console returned:

OpenCV(4.1.1) Error: Assertion failed (s >= 0) in cv::setSize, file C:\OpenCV\opencv-4.1.1\modules\core\src\matrix.cpp, line 235

I've tested the values returned using cout by pxd_imageYdim(), pxd_imageXdim() and they both returned negative values (-25). I wonder why.

Here's a snapshot of the system.cpp response: https://ibb.co/bdxFVTk

Vizier87 gravatar imageVizier87 ( 2019-10-08 04:16:16 -0500 )edit

i'm getting the 2nd exception properly using Mat m(-3,-3,0); but no idea about the 1st.

anyway, -25 looks wrong. maybe there have to be some steps before this, like opening the capture, setting modes, etc ?

berak gravatar imageberak ( 2019-10-08 04:38:10 -0500 )edit
1

answered 2019-10-09 01:01:18 -0500

Vizier87 gravatar image

You're right!

Here's the working code for future inquirers:

// Basic code for importing an image from a OWL 320 Camera into OpenCV.
// Special thanks for the essential part of the code to Berak of OpenCV forum. 
// Author: Vizier87

//EPIX Library
#include "windows.h"
#include "xcliball.h"


//OpenCV Library
#include <opencv2\highgui.hpp>
#include <opencv2\videoio.hpp>
#include <opencv2/opencv.hpp>

using namespace cv;
using namespace std;

Mat getPixels() {

    Mat img(pxd_imageYdim(), pxd_imageXdim(), pxd_imageCdim() == 1 ? CV_8UC1 : CV_8UC3);

    pxd_readuchar(0x1, 1, 0, 0, -1, -1, (uchar*)img.data,  // <-- here we pass allocated mem.
        pxd_imageXdim() * pxd_imageYdim() * pxd_imageCdim(),
        pxd_imageCdim() == 1 ? "Grey" : "RGB");

    return img;
}

int main() {

    pxd_PIXCIopen("", "Default", "");
    pxd_doSnap(0x1, 1, 0);


    imshow("test", getPixels());
    waitKey(0);
    pxd_PIXCIclose();

}
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-10-01 01:25:13 -0500

Seen: 31 times

Last updated: Oct 09