RGB2BGR option disappeared from cvtColor - c++

I'm trying to compile my code with opencv 3.0.0 (that worked with previous opencv versions)
cvtColor(img, img, CV_RGB2BGR);
and get compilation error
‘CV_RGB2BGR’ was not declared in this scope
The option also does not exist in the documentation
How can I get the same functionality (RGB2BGR) with the new version?

Use constant cv::COLOR_RGB2BGR instead of CV_RGB2BGR.
It works for other convertions too, just change CV_ to cv::COLOR_ .
Just checked it it works for me.

Maybe you have a namespace issue?
The enum is defined here, and in any case, it is exactly the same as CV_BGR2RGB - it just mixes the channels. You could also use mixChannels() directly.

Be careful, OpenCV 3 is something new, it is very probable that it has changed some macros and also functions and especially functionality. More it is not a stable versions, meaning it is still in dev. I have seen that there are some other names for the macros, like COLOR_RGB2BGR. The CV_RGB2BGR seems to be in types_c.h

Related

Can't use lldbbridge.py to inspect Qt objects because error in "wrapper prefix"

A little configuration information to start:
Xcode 13
Qt 5.15.5
iOS 14.7.1 (18G82) (I'm running on a device, not a
simulator)
Host MacOS Big Sur 11.6
I'm debugging a large Qt app, all written in C++, except for the necessary few files to make it work in iOS (so it's really an Objective-C++ app with an enormous amount of native C++ linked to it, everything of Qt it needs). I have a break point within the LoadApplication method - Qt has been built from source for development (that is, in debug configuration with symbols). There are a number of native Qt QUrl objects whose values I'd like to inspect. I have successfully installed lldbbridge.py, but I think the problem may be unrelated to that, because I saw it when I was using other tricks to see the data without the bridge. There is a method called toString on the QUrl class that produces a text representation of the URL (and another called toDisplayString that may be more human readable). These methods produce (of course) QString objects. So here are the failure modes:
First the bridge should be helping me to inspect the QUrl and all I see are the raw object descriptions that hide all the private interfaces. It isn't.
before I installed the lldbbridge.py script, I was able to view some of these objects (local variables, but not parameters), using code like expr url.toString().toStdString().c_str(). It still might work on local variables, but I would really like to be able to inspect parameters as well.
the error feedback I get is
error: <lldb wrapper prefix>:21198:9: module 'std' not found
#import std;
~~~~~~~^~~
this is a pretty legit error, because I have scoured my system and the internet for evidence of this std.framework whose existence is implied, and cannot find it, though its name suggests that it would be an assist to Objective-C or Swift to deal with std::string and the like. Possibly it was a thing in Xcode 12 that has been dropped in Xcode 13, but if so, it has no footprint on the web that I can find. Still, presumably Qt 5.15.5's lldbbridge.py was compiled and run and against it at some point in the recent past.
this isn't the only trick that doesn't work when inspecting a QString, with or without the bridge. I also tried expr (const wchar_t*)url.toString().toUtf16() and expr (const char*)url.toString().toUtf8() and so forth. The same error feedback results, complaining about the mysterious "std" framework or module.
and don't get too hung up on QUrl objects, because I get the same result with other QStrings.
one more symptom: if I do an expr #import std; in the lldb command line, it appears to work. That is, it gives no error feedback and appears to complete. This just makes the world weirder, because if exists, it must be hiding somewhere inside Xcode's contents, but I've done file searches in there, and see no evidence of such a thing. And if it does exist, why is the lldb wrapper prefix giving me grief? Could the wrapper be underspecified in terms of framework search paths, but the lldb command line not?
So as if it's not too obvious, here are my questions (besides WTF???):
Am I the first to see this? I've seen some forum talk about string inspection no longer working for others in Xcode 13 lldb, but the specific failure mode is different. Anyone else see this?
Does anyone have any idea about this mysterious "std" framework or module? Could its functionality have been sucked up into some other module or framework for Xcode 13?
Any ideas about work-arounds that I haven't thought of? I'm not a complete lldb novice, but I'm not an expert either.
I'd like to turn up the log levels look at those for clues, but I've never used that feature before, and I don't really even know where to FIND the logs.
I notice that the feedback suggests that there are at least 21198 lines in this "wrapper" BEFORE we get to the failing import statement. Seems a little excessive to wrap a request to view the contents of a string. Perhaps the whole wrapper is corrupted in some way. Any thoughts on how to test that hypothesis? How about a way to inspect the contents of the wrapper prefix itself?
Could the #import std; be a red herring and just co-lateral damage in some other unrelated failure mode? It's tempting to imagine it's some kind of std library support thing, but I don't want to assume too much at this point.
one more things about "std", whatever it is - lldb is super dynamic. It's always compiling inline code on-the-fly to support its functionality. That's the whole llvm magic. Is it possible it exists only as some inline text within lldb's source? And again, if so, why is it only selectively available?
Well, that's my nightmare. Unless my setup is horribly corrupted in some way and it's my unique curse, I'm sure this problem will show up for others, so cogent answers will make you a hero. Any pointers are appreciated. Thanks.

OpenCV CV_* functions error

I am having a bit of annoying problem with OpenCV CV_* constants for functions.
I know OpenCV has recently got rid of the CV_ for a lot of constants, however I can not find any updated documentation. And all the documentation that exits it still shows the old constants.
For example CV_BGR2GRAY has been switched to COLOUR_BGR2GRAY.
Where Can I find the new updated documentation for these constants like
CV_AA, CV_HOUGH_GRADIENT. (before someone says their original website, I have already checked and it shows older versions).
Any links would be nice.
Many thanks for your help.
Here's OpenCV 3.0 documentation:
http://docs.opencv.org/trunk/index.html
Conversion constants are described here:
http://docs.opencv.org/trunk/modules/imgproc/doc/miscellaneous_transformations.html

Where cv::adaptiveBilateralFilter has disappeared?

In OpenCV 2.4.9 there is a nice function cv::adaptiveBilateralFilter(). It is documented here http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=bilateralfilter#adaptivebilateralfilter
In OpenCV 3 (from GIT) all references to it has been removed. Even sample code is gone.
Can anybody explain reasons for removing it. Probably some other way to use cv::bilateralFilter() as adaptive? How?
Its been removed from 2.4 because of low quality.
( search https://github.com/Itseez/opencv for 'removed ABF' ).
But anything can happen as opencv-3 is not yet released. I guess, we just have to wait for the official changelog and perhaps alternate functionality.

Opencv 2.4 snakeImage C++

I have looked at the opencv 2.4 reference and I cannot find an equivalent of snakeImage. Therefore what other methods can I implement to achieve the same result?
Many Thanks
You can use the definition of the snake of previous releases (eg. opencv2.0).
snake opencv 2.0
It works efficiently.
This is one approach: Active Contour (Snake) with OpenCV
But search on Google, you'll find more interesting results.
It was moved to legacy.
Python binding: cv2.cv.SnakeImage()

Saving image as JPG -library?

I'd like to find a JPEG-writing library that can be statically linked (so there are no DLL dependencies). No JPEG-reading ability is required.
Edit: I got LibGD working, but it had one problem described here:
LibGD library is not working: crash when saving image
libjpeg is the most popular library for saving jpegs, but it can be a bit of a pain to use.
Edit, here is a simple example of how to use it. Look for the function juce_writeJPEGImageToStream.
Have you looked at LibGD? I can't seem to find the license, but neither did you specify a requirement.
If you're running your application on Windows then you should use the standard, built-in "GDI+" library that Microsoft provides. Every computer running XP or later has this library.
GDI+ is intended to supersede GDI, which is what you're probably already using whether you know it or not, but it can co-exist with GDI calls provided you flush the buffers when switching between the two. See:
http://www.cpjj.net/Miscellaneous/CreateJPEGFromDC.htm
(Hans Passant - you should have written your comment as an answer).