Solved Qt + OpenCV lib for IOS first configuration failed
I just started qt project with opencv framework for an ios program.
i just believe i config opencv by cmake correctly and put opencv file in my documents in finder
and i just try to add opencv to qt project by pri file
and this is my pri file inside
so there are 2 fail when i try to build project
first one is opencv2/opencv.hpp file not found, i think is is about what is written in pri file but i dont know what i can write it there, i just take this part from a book
second one is xcodebuild failed, and this is about xcode but xcode is fine i think
can you give me a hint?
Xcodebuild failed because it couldn't find
opencv.hpp. Did you check its exact location on your machine ?
VRonin last edited by
my user name kontrolog on computer and i told you i put opencv in document
where is opencv.hpp
it is there like below
Then why are you using a .pri file that points everything to
i just copy from book.
I dont know file system of mac, i download source code zip and put the file inside of the zip to document, and i made a file as name build inside the file opencv and build it. it is all taken from a book. Maybe i dont understand what i did.
in the end i think cmake put the builded opencv files into build file, i just click configure and generate
i use cmake and it fills build file
The filesystem layout follows to some extend the classic Unix style.
From the looks of it, you are rather building OpenCV for the desktop.
Why build from source since they seem to provide pre-built binaries for iOS ?
i couldnt use it if i know how can i add it i was planning to work with it. as i told, i have a book and i am working on it it explain as like this. i write program same but framework adding is not i made it before.
i didnt understand steps. when i download prebuilt binaries for ios there is no explanation how to set up to my project. i am writing and make it again. please lead me to finish what i did. Now i began
I downloaded opencv ios pact. now it is in my download dir.
i press cmd+shift+h and make a dir which name is opencv
- i put ios-pact zip file in this dir and extract it same place
- now i open my qt project and connect opencv and qt once for test app. so i need a pri file or sthing. please tell me what i will do next to add opencv to my project.
After all i made it just once and i can use it if i know how i made it.
LIBS += -F/path/to/opencv -framework opencv2
-Fis the equivalent of
-Lbut for macOS/iOS frameworks.
-frameworkis the equivalent of
-lbut for macOS/iOS frameworks.
am i understand right. i just wright "LIBS += -F/path/to/opencv -framework opencv2" to pri file and i will create pri file where and how can i add it to path or something what i dont know now :) i am sorry as you understand i just try to make a program with qt + opencv to my personal i phone. later i will convert it also android but the main idea is iphone now.
i am working on amin ahmadi tazehkandi's book it is not many information about ios part of programming and it is a little bit harder i think this must be the reason. maybe later mr. tazehkandi makes a unity education system for ios, i would like to be the first customer of it :)
but i dont know to much. i think i need some push than i can go by myself.
what can i add main.cpp to work with opencv framework codes as you see in below
"Mat image = imread("/Users/kontrolog/Desktop/test1.png");"
thanks a lot.
@kybernetes You need to include OpenCV header file(s) you need in your main.cpp
how can i add it to my main.cpp
as you see when i tried to add by include there is no opencv or opencv2, i appears only opencl-c.h and it is not about me.
for example "Mat image = imread("/Users/kontrolog/Desktop/test1.png");" if i play this code, what i can add my main.cpp file and how.
as you see i put opencv2.framework file in opencv dir where is here "/Users/kontrolog/opencv/" and inside of it
and i put my pri file is also opencv dir
and inside of my pri file is i add headers line now and i make qmake again project file but it didnt work
and after it i cleared headers line in pri file and by right click on source add existing file
i add headers opencv.hpp file from that path "/Users/kontrolog/opencv/opencv2.framework/Versions/A/Headers"
but it also doesnt work and i take same error again.
@kybernetes You should NOT add header files from OpenCV via "Add Existing Files..."!
You just need to find out where needed header files are. To use Mat you need mat.hpp. It should be somewhere inside Headers directory, simply search for it.
i really thanks to trying help me but i dont know how to add it.
in my book there is a sample code. so i tried to add "opencv2/opencv.hpp" and writer used this hpp files for OSX, he first qmake the opencv source file than add his program. in my problem it is not for MacOSX for IOS and i download ios pack from opencv website so i couldnt add my project the framework or header files as you see. i think opencv.hpp header is enough for Mat function because of the book. But i can find mat.hpp file it doesnt matter. after i find the file what should i do how can i add header file to my project by not being right click add existing file.
should i copy the mat.hpp file inside from framework and paste to my project file?
i really didnt understand how can i add file and this basic program work on ios simulator :)
i couldnt find mat.hpp file inside of opencv dir. but i find opencv.hpp and copy paste to my project file than i build it.
ios simulator is worked but it gives an error lite this and i didnt see the picture, program is now worked.
As the error suggest, imshow's backend is not implemented for iOS but that's something you'd have to look with the OpenCV folks.
On a side note, if you want to show something with your Qt application then QCoreApplication is not the right tool as it doesn't start any graphical backend. It's for command line tools.
On a side note, loading a file from your main machine Desktop folder also won't work on your device as the file won't be accessible.
about error suggest, i just download opencv ios pack from opencv website as i told so i didnt understand that.
side note 1: i will change QCoreApplication, i just copied the sample code from the book.
Side note 2: i thought also as you, i think if i show a picture i should add it to my project file at least. maybe this can be a solution for access the photo
Building OpenCV for iOS by hand or using their pre-built package won't change anything: the
highguidoesn't seem to have backend for iOS.
What exact book are you using ?
What are you going to use OpenCV for exactly ?
this is the book which i use
and i want to use it just because of fast and useful about image proccesing.
İmage processing is not to much i just want to reach my phone's photo lib, choose photo, crop, rotate and contras it. than make its size smaller but not much effect photo than upload my webserver. that is all i want to. I want to use qml for pages.
Maybe opencv is too much for my needs but i just dont want to effect photo too much when i resize its size.
if you advice any other solution i can give up opencv now :) for ios and android at least
Why not use QImage ?
at the and i will. as i say i was trying to study step by step from book, and i like study from book now the problem how can i use QImage how i can reach file system, how i crop as i want and how i resize etc...
where can i learn, i check but not use too much time, there is no qt ios book or there is not a unity education. so how can i learn proffesional and ask only the necessary question.
you are so helpful and thank you for that but as you know it is impossible to ask everthing to you, and i am write a game for ios and android before 2 years ago i am not an expert, i have to take help every step of the program to learn good and make a good program.
Now i will use QImage we can think that, and i need to use qml to make apperiance more usefull for app.
i am asking Qml + QImage + IOS + Android for documantation. I need take photo from iphone photo library, crop it, rotate it, change contras and upload webserver, at this time program has to be flexible for all phones, apperiance has to be same iphone 4 5 6 7 8 10 or android device and it was hard to do 2 years ago when i was trying to write a game.
Thanks. please give me an advice than, and i will ask any other problems here.