mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 06:26:29 +08:00
Added interface to check library version during runtime
This commit is contained in:
parent
875b4e212a
commit
d2cff38db6
@ -247,6 +247,23 @@ architecture.
|
|||||||
*/
|
*/
|
||||||
CV_EXPORTS_W const String& getBuildInformation();
|
CV_EXPORTS_W const String& getBuildInformation();
|
||||||
|
|
||||||
|
/** @brief Returns library version string
|
||||||
|
|
||||||
|
For example "3.4.1-dev".
|
||||||
|
|
||||||
|
@sa getMajorVersion, getMinorVersion, getRevisionVersion
|
||||||
|
*/
|
||||||
|
CV_EXPORTS_W String getVersionString();
|
||||||
|
|
||||||
|
/** @brief Returns major library version */
|
||||||
|
CV_EXPORTS_W int getVersionMajor();
|
||||||
|
|
||||||
|
/** @brief Returns minor library version */
|
||||||
|
CV_EXPORTS_W int getVersionMinor();
|
||||||
|
|
||||||
|
/** @brief Returns revision field of the library version */
|
||||||
|
CV_EXPORTS_W int getVersionRevision();
|
||||||
|
|
||||||
/** @brief Returns the number of ticks.
|
/** @brief Returns the number of ticks.
|
||||||
|
|
||||||
The function returns the number of ticks after the certain event (for example, when the machine was
|
The function returns the number of ticks after the certain event (for example, when the machine was
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
// these constants are wrapped inside functions to prevent inlining
|
// these constants are wrapped inside functions to prevent inlining
|
||||||
private static String getVersion() { return "@OPENCV_VERSION@"; }
|
private static String getVersion() { return "@OPENCV_VERSION@"; }
|
||||||
private static String getNativeLibraryName() { return "opencv_java@OPENCV_VERSION_MAJOR@@OPENCV_VERSION_MINOR@@OPENCV_VERSION_PATCH@"; }
|
private static String getNativeLibraryName() { return "opencv_java@OPENCV_VERSION_MAJOR@@OPENCV_VERSION_MINOR@@OPENCV_VERSION_PATCH@"; }
|
||||||
private static int getVersionMajor() { return @OPENCV_VERSION_MAJOR@; }
|
private static int getVersionMajorJ() { return @OPENCV_VERSION_MAJOR@; }
|
||||||
private static int getVersionMinor() { return @OPENCV_VERSION_MINOR@; }
|
private static int getVersionMinorJ() { return @OPENCV_VERSION_MINOR@; }
|
||||||
private static int getVersionRevision() { return @OPENCV_VERSION_PATCH@; }
|
private static int getVersionRevisionJ() { return @OPENCV_VERSION_PATCH@; }
|
||||||
private static String getVersionStatus() { return "@OPENCV_VERSION_STATUS@"; }
|
private static String getVersionStatusJ() { return "@OPENCV_VERSION_STATUS@"; }
|
||||||
|
|
||||||
public static final String VERSION = getVersion();
|
public static final String VERSION = getVersion();
|
||||||
public static final String NATIVE_LIBRARY_NAME = getNativeLibraryName();
|
public static final String NATIVE_LIBRARY_NAME = getNativeLibraryName();
|
||||||
public static final int VERSION_MAJOR = getVersionMajor();
|
public static final int VERSION_MAJOR = getVersionMajorJ();
|
||||||
public static final int VERSION_MINOR = getVersionMinor();
|
public static final int VERSION_MINOR = getVersionMinorJ();
|
||||||
public static final int VERSION_REVISION = getVersionRevision();
|
public static final int VERSION_REVISION = getVersionRevisionJ();
|
||||||
public static final String VERSION_STATUS = getVersionStatus();
|
public static final String VERSION_STATUS = getVersionStatusJ();
|
||||||
|
@ -2048,4 +2048,11 @@ public class CoreTest extends OpenCVTestCase {
|
|||||||
assertEquals(5f, val2);
|
assertEquals(5f, val2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testVersion() {
|
||||||
|
assertEquals(Core.VERSION_MAJOR, Core.getVersionMajor());
|
||||||
|
assertEquals(Core.VERSION_MINOR, Core.getVersionMinor());
|
||||||
|
assertEquals(Core.VERSION_REVISION, Core.getVersionRevision());
|
||||||
|
assertEquals(Core.VERSION, Core.getVersionString());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -745,6 +745,14 @@ const String& getBuildInformation()
|
|||||||
return build_info;
|
return build_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getVersionString() { return String(CV_VERSION); }
|
||||||
|
|
||||||
|
int getVersionMajor() { return CV_VERSION_MAJOR; }
|
||||||
|
|
||||||
|
int getVersionMinor() { return CV_VERSION_MINOR; }
|
||||||
|
|
||||||
|
int getVersionRevision() { return CV_VERSION_REVISION; }
|
||||||
|
|
||||||
String format( const char* fmt, ... )
|
String format( const char* fmt, ... )
|
||||||
{
|
{
|
||||||
AutoBuffer<char, 1024> buf;
|
AutoBuffer<char, 1024> buf;
|
||||||
|
@ -189,4 +189,14 @@ TEST(Core_Parallel, propagate_exceptions)
|
|||||||
}, cv::Exception);
|
}, cv::Exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(Core_Version, consistency)
|
||||||
|
{
|
||||||
|
// this test verifies that OpenCV version loaded in runtime
|
||||||
|
// is the same this test has been built with
|
||||||
|
EXPECT_EQ(CV_VERSION_MAJOR, cv::getVersionMajor());
|
||||||
|
EXPECT_EQ(CV_VERSION_MINOR, cv::getVersionMinor());
|
||||||
|
EXPECT_EQ(CV_VERSION_REVISION, cv::getVersionRevision());
|
||||||
|
EXPECT_EQ(String(CV_VERSION), cv::getVersionString());
|
||||||
|
}
|
||||||
|
|
||||||
}} // namespace
|
}} // namespace
|
||||||
|
Loading…
Reference in New Issue
Block a user