Carnival LiveCam, augmented reality made easy
-
This looks very cool hipersayan_x :)
-
Thanks :D
-
Why is the title of the last dialog you show "Dialog"? That is not very descriptive...
-
Because I forget to change that XD
I did that driver at the last moment for test purposes. -
Hi Hipersayan_x.
I've found your application very usefull and suitable , enough novice and unigue for our times.
Trying to build , run test and understand the application.
I've got segmentation fault when run on my Ubuntu 84 bit:inside shellmanager.cpp
this->activeShell->widget()
returns null.
Didn't get yet how do you implement ( realize )shell class? There is only header shell.h
...
Thanks.
-
The most likely reason is that you was not built the shell. Build the shell with:
@cd Carnival-LiveCam/share/shells/DefaultShell
qmake && make@Or build DefaultShell.pro from Qt Creator.
Or better yet, build all the proyect:@cd Carnival-LiveCam
./build_all.sh@If followed the steps correctly, running the program, you should see output similar to this:
@Loading: "/home/hipersayan_x/Carnival-LiveCam/share/drivers/ImageDriver/libImageDriver.so"
Loading: "/home/hipersayan_x/Carnival-LiveCam/share/drivers/VideoDriver/libVideoDriver.so"
Loading: "/home/hipersayan_x/Carnival-LiveCam/share/drivers/WebcamLinux/libWebcamLinux.so"
Loading: "/home/hipersayan_x/Carnival-LiveCam/share/shells/DefaultShell/libDefaultShell.so"
Loading: "/home/hipersayan_x/Carnival-LiveCam/share/plugins/DefaultPlugin/libDefaultPlugin.so"
Loading: "/home/hipersayan_x/Carnival-LiveCam/share/plugins/SnowFall/libSnowFall.so"
Loading: "/home/hipersayan_x/Carnival-LiveCam/share/plugins/TheMask/libTheMask.so"@ -
Succeed to run. I built the parts from QtCreator but linked to opencv using package config :
unix {
CONFIG += link_pkgconfig
PKGCONFIG += opencv
}I am thinking how to prepare installer or shell script to install the application together with third party dependencies ( OpenCV ) on end-user machine using one-click ( one run ).
Does the software work on ARM processors, 800-1000HZ, 1GB memory with Linux based platform?
Have it been tested on Embedded Linux kernels? if yes what kernels tested?Thanks.
-
Wow, thank you! PKGCONFIG option is new for me, I will add this to devel branch.
bq. I am thinking how to prepare installer or shell script to install the application together with third party dependencies ( OpenCV ) on end-user machine using one-click ( one run ).
That would be great! That's what I want.
bq. Does the software work on ARM processors, 800-1000HZ, 1GB memory with Linux based platform?
No, only tested on x86-64 processors, I haven't a tablet PC. But I'm interested in make it work on tablet devices, the current design is intended for that.
The current testing plataform is a Lenovo G550 (a laptop) with:- Pentium Dual-Core CPU T4400 @ 2.20GHz (64 bits)
- 4 Gb of RAM
- Intel GMA 4500M graphics card (256 MB).
- 2 webcams with a resolution of 300k pixels. (U_u) Snif, snif.
bq. Have it been tested on Embedded Linux kernels? if yes what kernels tested?
No, only on normal kernels, kernel version = 3.1.7 for 64 bits
-
Ok
I am interesting these days in the OpenCV - Qt integration.
Maybe you can advice me as a developer of this software.
I have one another question ( maybe interesting ):
When I open webcam at my place using openCV by next code:cv::VideoCapture m_Camera = cv::VideoCapture();
m_Camera.open(0);I observe a bit confusing unpleasant high delay between press button and actual start of displaying video stream ( suppose by button press above code instructions called ) that I research how to minimize.
I observe the led of webcam ( embedded camera in laptop ) is lighted almost immidiately ( after 1 sec ) but I see frames of video on my widget where I render frames from web cam only after 2 - 4 sec and that is high perceptible delay. that should be removed--Why such delay ( what is source of the delay ). How to minimize it ?
--What is a delay between call to m_Camera.open(0) to frames stream displayed at your platform ?
--There is another option to get frames from camera using openCV by
CvCapture *m_Camera = cvCreateCameraCapture(0);
...but then you should convert IplImage to QImage and I see yet only solutions with 2 loops for conversion while option you use with cv::Mat frame; - you convert in one row that is of course preferable than 2 long loops - reduces execution time ( maybe usefull note FYI to reduce execution times if will port in future on small resource/time critical systems ( embedded ) ). -
Thank you in advance.
-
bq. --Why such delay ( what is source of the delay ). How to minimize it ?
Perhaps it is because of the different stages through which must pass signals or frames to be processed.
The calling trace for a device activation is:
@
// Connect the signal from device selection button to another slot...
bool ShellManager::enableShell(QString id)
{
connect(this->activeShell, SIGNAL(deviceSelected(QString)), this, SLOT(onDeviceSelected(QString)));
}// then emmit the signal. Is there possible to connect a signal directly to another signal?
void ShellManager::onDeviceSelected(QString deviceId)
{
emit deviceSelected(deviceId);
}// Connect the signal emmited from the ShellManager...
Core::Core(QObject *parent): QObject(parent)
{
connect(&this->shellManager, SIGNAL(deviceSelected(QString)), this, SLOT(deviceSelected(QString)));
}// to this slot and then setup the new device and update the viewport on PluginManager.
void Core::deviceSelected(QString deviceId)
{
this->deviceManager.setDevice(deviceId);
this->pluginManager.resize(this->deviceManager.frameSize());
}// Setup de new device.
bool DeviceManager::setDevice(QString id)
{
if (this->devicesInfo[this->activeDevice].driverId() != this->devicesInfo[id].driverId())
{
// If the current device and the new selected device uses a diferent driver,
// disable the current device and unload the driver (unload the QtPlugin from memory),
this->disableDevice(this->activeDevice);// and load the new driver and setup the new device. this->enableDevice(id); } else { // Both, the current device and the new selected device uses the same driver, // Just get a reference to the current loaded driver. Driver *driver = this->driverManager.driver(this->devicesInfo[id].driverId()); if (driver) { // Disable the current device, driver->disableDevice(this->activeDevice); // and load the new device. driver->enableDevice(id); } }
}
// For example, the new device is a webcam.
bool WebcamLinux::enableDevice(QString id)
{
cv::VideoCapture webcam;// Try to open webcam device, if (!webcam.open(QString(id).remove("/dev/video").toInt())) return false; // and append it to activeWebcams. this->activeWebcams[id] = webcam; return true;
}
@The calling trace for frames retrieve and show is:
@
// MediaStreamming emmit a new captureFrame every 1ms.
Core::Core(QObject *parent): QObject(parent)
{
connect(&this->mediaStreaming, SIGNAL(captureFrame()), this, SLOT(captureFrame()));
}void Core::captureFrame()
{
// Capture a frame from DeviceManager, send it to PluginManager to apply the effects,
// and return the frame with the effects applied.
QImage frame = this->pluginManager.getFrame(this->deviceManager.captureFrame());// Send the frame to MediaStreamming for save it to a video or image file. this->mediaStreaming.setFrame(frame); // And send it to the current shell. this->shellManager.setFrame(frame);
}
// Caspturing a frame from a device.
QImage DeviceManager::captureFrame()
{
if (this->activeDevice != "")
{
// Get a reference to the current loaded driver.
Driver *driver = this->driverManager.driver(this->devicesInfo[this->activeDevice].driverId());if (driver) // Capture a frame from the current device. return driver->captureFrame(this->activeDevice); } // Else return a 1x1 black image. QImage frame(1, 1, QImage::Format_RGB888); frame.fill(0); return frame;
}
// Caspturing a frame from a webcam.
QImage WebcamLinux::captureFrame(QString id)
{
if (this->activeWebcams.contains(id))
{
cv::Mat matFrame;// Capture a frame in cvMat format... this->activeWebcams[id] >> matFrame; // and convert it to QImage. QImage qtFrame((const uchar *)matFrame.data, matFrame.cols, matFrame.rows, QImage::Format_RGB888); return qtFrame.rgbSwapped(); } else { // Else return a 1x1 black image. QImage frame(1, 1, QImage::Format_RGB888); frame.fill(0); return frame; }
}
// Here we apply all the active candys (effects) to the frame.
QImage PluginManager::getFrame(const QImage &image)
{
QImage frame = image;for (int currentPlugin = 0; currentPlugin < this->activePlugins.size(); currentPlugin++) frame = this->activePlugins[currentPlugin]->render(frame); return frame;
}
@BUT, still is necessary to add a new stage after processing the frames and before displaying it in the shell, the Spaces. The Spaces allow you to display several devices at same time. I'm working on that right now.
bq. --What is a delay between call to m_Camera.open(0) to frames stream displayed at your place?
I think just 1 or 2 seconds.
bq. --There is another option to get frames from camera using openCV by ...
Yes, before releasing Carnival LiveCam, I was using the C API of OpenCV, with the same results as the C++ API, no timing difference.
-
Ok, I was discovered the frame delay bug, disable the webcam, wait 2 or 3 seconds, and enable again. Apparently, it is not related to OpenCV. Working on that.