opencv cv::VideoCapture indecipherable errors - c++

OpenCV version 3.4.3
Xcode version 10.1 (10B61)
macOS version 10.14.2 (18C54) Mojave
I am using C++ to run an extremely simple program.
This code is used to access the macbook webcam.
#include <iostream>
#include <opencv2/opencv.hpp>
int main() {
cv::VideoCapture camera(0);
return 0;
}
These are the messages from the Xcode console.
I couldn't find any resources to debug this situation.
CMIO_Unit_ScopeElement.h:200:SafeGetElement Throwing err: -67454
CMIOUnitFigBaseObjectImpl.c:246:CMIOUnitCreateFromDescription Invalid paramater
CMIO_Unit_Input_Device.cpp:244:GetPropertyInfo CMIOUInputFromProcs::GetPropertyInfo() failed for id 102, Error: -67456
CMIO_DAL_PlugIn.cpp:269:StreamCopyBufferQueue got an error from the plug-in routine, Error: 1852797029
CMIOHardware.cpp:339:CMIOObjectGetPropertyData the System is exiting
CMIOHardware.cpp:339:CMIOObjectGetPropertyData the System is exiting
Program ended with exit code: 0

Related

Why is the emoji displays incorrectly in Windows Terminal?

I try to use C++ to output a emoji and below is the code. I wrote this in VS Code.
#include <iostream>
int main() {
std::cout << "😊";
return 0;
}
Then I try to compile this code with Clang++ and get a .exe file. But when I run the .exe file in Windows Terminal it doesn't display correctly.
Below is what I get when I run the file.
PS C:\Users\26354> D:\Code_exercise\Assignment\Class\Bin\Temp.exe
馃槉
PS:
Clang version 13.0.1
Target: x86_64-pc-windows-msvc
Windows Terminal Version: 1.12.10393.0
VS Code Version: 1.64.2
Windows Version: Windows 10 Pro 21H2

Dev cpp - Error while running: not a valid Win32 application

I have recently started with C++ and am using Dev cpp as my IDE. But whenever I compile and run the program for Dev cpp, the program compiles successfully but while running the .exe file I get the following error:
--------------------------------
Failed to execute "C:\Users\Karan Gandhi\Desktop\Untitled1.exe":
Error 193: %1 is not a valid Win32 application.
Press any key to continue . . .
Here is my program:
#include <iostream>
using namespace std;
int main() {
cout << "Hello world";
return 0;
}
Please Note: I can successfully run the program from the terminal manually by just opening the file in the terminal: "C:\Users\Karan Gandhi\Desktop\Untitled1.exe"
Is there any way to fix this? Thank you!

Set up SDL2 on Mac Clion or XCode

I was trying to set up SDL2 on Mac Clion and XCode and both have occurred some problems. This is what I got from XCode:
2020-07-16 23:42:59.224392-0700 Trying_See_if_SDL2_Works[78612:8627338] Metal API Validation Enabled
2020-07-16 23:42:59.287864-0700 Trying_See_if_SDL2_Works[78612:8628129] flock failed to lock maps file: errno = 35
2020-07-16 23:42:59.288955-0700 Trying_See_if_SDL2_Works[78612:8628129] flock failed to lock maps file: errno = 35
Program ended with exit code: 0
And this is the code I used for testing: (C++)
#include "/Library/Frameworks/SDL2.framework/Headers/SDL.h"
#include <iostream>
int main() {
if (SDL_Init(SDL_INIT_VIDEO)!=0){
std::cout<<"SDL Init Error: "<<SDL_GetError();
return 1;
}
SDL_Quit();
return 0;
}
Can anyone give some advice on how to set up frameworks properly on Clion?

opencv_contrib unable to compile program (even though build was successful) with OpenCV 3.0.0 beta

I installed the latest version of opencv (OpenCv 3.0.0 Beta). I downloaded the opencv_contrib module and built it with opencv by doing a cmake (by following the instructions in the readme https://github.com/itseez/opencv_contrib). The build happened successfully. I wrote a simple program which uses creates a BasicFaceRecognizer model. However, when I compile my program I get the following error message
fatal error: opencv2/face.hpp: No such file or directory
#include"opencv2/face.hpp"
The code is very simple. Just wanted to check if it compiles before proceeding further.
#include"opencv2/opencv_modules.hpp"
#include"opencv2/face.hpp"
using namespace cv;
using namespace cv::face;
int main()
{
Ptr<BasicFaceRecognizer> model = createEigenFaceRecognizer();
return 0;
}

OpenCV C++ code runs fine in terminal but error in running from eclipse - Ubuntu 12.04

I am trying to run C++ OpenCV programs in Eclipse IDE on Ubuntu 12.04 LTS. They run fine when I use the terminal, as shown here-https://help.ubuntu.com/community/OpenCV.
But when I build the same code in Eclipse, I get the following error
Error description-
opengl support available
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /home/akash/OpenCV/opencv-2.4.7/modules/highgui/src/window.cpp, line 269
terminate called after throwing an instance of 'cv::Exception'
what(): /home/akash/OpenCV/opencv-2.4.7/modules/highgui/src/window.cpp:269: error: (-215) size.width>0 && size.height>0 in function imshow
My code is
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat img=imread("image.jpg");
namedWindow("win",WINDOW_AUTOSIZE);
imshow("win",img);
waitKey(0);
return 1;
}
I have taken care of the following-
kept the image.jpg in src and all other folders of the project.
double-checked the library names in /usr/local/lib
Added only a single include path for OpenCV header files.
I still cant seem to run it.
Please help.
I still think your problem comes from the program not finding the image.jpg file (even if you have taken a number of steps to make sure it does). The working directory - that an application is executed from - is often different from that of the source or binary folders in eclipse (you can actually set it manually in project settings).
To quickly verify this hypothesis you could pass the absolute path of image.jpg to imread(). If that solves the problem you just need to configure your working directory correctly in eclipse.
g++ filename.cpp -o outputfile-name pkg-config --cflags --libs opencv
Ex:
Compilation:-
thinkpadt61#thinkpadt61-ThinkPad-T61:~/Kannathasan$ g++ simple.cpp -o sample pkg-config --cflags --libs opencv
Run:
thinkpadt61#thinkpadt61-ThinkPad-T61: ./sample
Thats it!... Enjoy