mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 03:00:14 +08:00
Merge pull request #24946 from alexlyulkov:al/kotlin-tests2
Added Kotlin test, changed Kotlin version for OpenCV
This commit is contained in:
commit
6c21a80ef7
@ -2,7 +2,7 @@
|
||||
set(ANDROID_GRADLE_PLUGIN_VERSION "7.3.1" CACHE STRING "Android Gradle Plugin version")
|
||||
message(STATUS "Android Gradle Plugin version: ${ANDROID_GRADLE_PLUGIN_VERSION}")
|
||||
|
||||
set(KOTLIN_PLUGIN_VERSION "1.5.20" CACHE STRING "Kotlin Plugin version")
|
||||
set(KOTLIN_PLUGIN_VERSION "1.8.20" CACHE STRING "Kotlin Plugin version")
|
||||
message(STATUS "Kotlin Plugin version: ${KOTLIN_PLUGIN_VERSION}")
|
||||
|
||||
if(BUILD_KOTLIN_EXTENSIONS)
|
||||
|
@ -10,12 +10,13 @@ set(ANDROID_TESTS_SRC_DIRS
|
||||
|
||||
set(ANDROID_TESTS_RES_DIR "'${OpenCV_SOURCE_DIR}/modules/java/test/common_test/res'" CACHE INTERNAL "")
|
||||
|
||||
list(APPEND TEST_PROJECT_FILES "build.gradle" "CMakeLists.txt" "gradle.properties" "settings.gradle")
|
||||
list(APPEND TEST_PROJECT_FILES "CMakeLists.txt" "gradle.properties" "settings.gradle")
|
||||
foreach(TEST_PROJECT_FILE ${TEST_PROJECT_FILES})
|
||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_PROJECT_FILE}" DESTINATION "${OPENCV_ANDROID_TEST_DIR}")
|
||||
endforeach()
|
||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests_module/AndroidManifest.xml" DESTINATION "${OPENCV_ANDROID_TEST_DIR}/tests_module")
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tests_module/build.gradle.in" "${OPENCV_ANDROID_TEST_DIR}/tests_module/build.gradle" @ONLY)
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/build.gradle.in" "${OPENCV_ANDROID_TEST_DIR}/build.gradle" @ONLY)
|
||||
|
||||
file(COPY "${OpenCV_SOURCE_DIR}/platforms/android/gradle-wrapper/gradlew" DESTINATION "${OPENCV_ANDROID_TEST_DIR}")
|
||||
file(COPY "${OpenCV_SOURCE_DIR}/platforms/android/gradle-wrapper/gradlew.bat" DESTINATION "${OPENCV_ANDROID_TEST_DIR}")
|
||||
|
@ -7,8 +7,8 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.3.1'
|
||||
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20'
|
||||
classpath 'com.android.tools.build:gradle:@ANDROID_GRADLE_PLUGIN_VERSION@'
|
||||
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:@KOTLIN_PLUGIN_VERSION@'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
@ -0,0 +1,25 @@
|
||||
package org.opencv.test.android
|
||||
|
||||
import org.opencv.core.CvType
|
||||
import org.opencv.core.Mat
|
||||
import org.opencv.core.times
|
||||
import org.opencv.test.OpenCVTestCase
|
||||
import kotlin.math.abs
|
||||
|
||||
class KotlinTest : OpenCVTestCase() {
|
||||
fun testMatrixMultiplication() {
|
||||
val m1 = Mat.ones(2, 3, CvType.CV_32F)
|
||||
val m2 = Mat.ones(3, 2, CvType.CV_32F)
|
||||
|
||||
val m3 = m1.matMul(m2)
|
||||
val m4 = m1 * m2
|
||||
|
||||
val value1 = floatArrayOf(3f)
|
||||
m3.get(0, 1, value1)
|
||||
|
||||
val value2 = floatArrayOf(5f)
|
||||
m4[0, 1, value2]
|
||||
|
||||
assertGE(0.001, abs(value1[0] - value2[0]).toDouble())
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
|
||||
android {
|
||||
namespace 'org.opencv.tests'
|
||||
|
@ -9,7 +9,7 @@ cmake_common_vars = {
|
||||
# Docs: https://developer.android.com/studio/releases/gradle-plugin
|
||||
'ANDROID_GRADLE_PLUGIN_VERSION': '7.3.1',
|
||||
'GRADLE_VERSION': '7.5.1',
|
||||
'KOTLIN_PLUGIN_VERSION': '1.5.20',
|
||||
'KOTLIN_PLUGIN_VERSION': '1.8.20',
|
||||
}
|
||||
ABIs = [
|
||||
ABI("2", "armeabi-v7a", None, ndk_api_level=ANDROID_NATIVE_API_LEVEL, cmake_vars=cmake_common_vars),
|
||||
|
Loading…
Reference in New Issue
Block a user