opencv 연결
@@ -26,6 +26,13 @@ android {
|
||||
viewBinding true
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path "src/main/cpp/CMakeLists.txt"
|
||||
version "3.10.2"
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
@@ -40,9 +47,11 @@ dependencies {
|
||||
implementation 'com.github.bumptech.glide:glide:4.9.0'
|
||||
implementation 'com.ramotion.foldingcell:folding-cell:1.2.3'
|
||||
implementation files('C:\\lib\\jdbc\\ojdbc6.jar')
|
||||
implementation project(path: ':OpenCV')
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
|
||||
implementation 'com.rmtheis:tess-two:9.0.0'
|
||||
implementation fileTree(dir: 'C:\\lib\\libs-wsmr', include: ['*.aar', '*.jar'], exclude: [])
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
<uses-permission android:name="android.permission.ACCESS_SUPERUSER" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
|
||||
<uses-feature android:name="android.hardware.camera"/>
|
||||
<uses-feature android:name="android.hardware.camera" />
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" />
|
||||
<uses-feature android:name="android.hardware.location.gps" />
|
||||
|
||||
@@ -21,20 +21,30 @@
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:largeHeap="true"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:largeHeap="true"
|
||||
android:theme="@style/Theme.QTagger"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".Activity.CameraActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".Activity.SyncActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".Activity.MoreActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".Activity.SettingActivity"
|
||||
android:exported="false" />
|
||||
@@ -82,7 +92,6 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
BIN
app/src/main/assets/7seg.traineddata
Normal file
BIN
app/src/main/assets/7seg_sample.traineddata
Normal file
BIN
app/src/main/assets/d02.traineddata
Normal file
BIN
app/src/main/assets/d03.traineddata
Normal file
BIN
app/src/main/assets/d04.traineddata
Normal file
BIN
app/src/main/assets/d05.traineddata
Normal file
BIN
app/src/main/assets/digits.traineddata
Normal file
BIN
app/src/main/assets/digits1.traineddata
Normal file
BIN
app/src/main/assets/eng.traineddata
Normal file
BIN
app/src/main/assets/jjh.traineddata
Normal file
BIN
app/src/main/assets/jjh2.traineddata
Normal file
BIN
app/src/main/assets/jjh_train.traineddata
Normal file
BIN
app/src/main/assets/kor.traineddata
Normal file
BIN
app/src/main/assets/letsgodigital.traineddata
Normal file
BIN
app/src/main/assets/nse.traineddata
Normal file
BIN
app/src/main/assets/nsetest.traineddata
Normal file
BIN
app/src/main/assets/weight01.jpg
Normal file
|
After Width: | Height: | Size: 3.1 MiB |
BIN
app/src/main/assets/weight02.jpg
Normal file
|
After Width: | Height: | Size: 3.1 MiB |
BIN
app/src/main/assets/weight03.jpg
Normal file
|
After Width: | Height: | Size: 3.2 MiB |
BIN
app/src/main/assets/weight04.jpg
Normal file
|
After Width: | Height: | Size: 3.2 MiB |
BIN
app/src/main/assets/weight05.jpg
Normal file
|
After Width: | Height: | Size: 3.1 MiB |
BIN
app/src/main/assets/weight06.jpg
Normal file
|
After Width: | Height: | Size: 3.3 MiB |
60
app/src/main/cpp/CMakeLists.txt
Normal file
@@ -0,0 +1,60 @@
|
||||
# For more information about using CMake with Android Studio, read the
|
||||
# documentation: https://d.android.com/studio/projects/add-native-code.html
|
||||
|
||||
# Sets the minimum version of CMake required to build the native library.
|
||||
|
||||
cmake_minimum_required(VERSION 3.4.1)
|
||||
|
||||
set(pathPROJECT D:/QTagger/a/QTagger_Android8)
|
||||
set(pathOPENCV D:/QTagger/a/QTagger_Android8/OpenCV)
|
||||
set(pathLIBOPENCV_JAVA D:/QTagger/a/QTagger_Android8/OpenCV/native/libs/${ANDROID_ABI}/libopencv_java4.so)
|
||||
|
||||
set(CMAKE_VERBOSE_MAKEFILE on)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
|
||||
|
||||
include_directories(${pathOPENCV}/native/jni/include)
|
||||
|
||||
# Creates and names a library, sets it as either STATIC
|
||||
# or SHARED, and provides the relative paths to its source code.
|
||||
# You can define multiple libraries, and CMake builds them for you.
|
||||
# Gradle automatically packages shared libraries with your APK.
|
||||
|
||||
add_library( # Sets the name of the library.
|
||||
native-lib
|
||||
|
||||
# Sets the library as a shared library.
|
||||
SHARED
|
||||
|
||||
# Provides a relative path to your source file(s).
|
||||
${pathPROJECT}/app/src/main/cpp/native-lib.cpp)
|
||||
|
||||
|
||||
add_library(lib_opencv SHARED IMPORTED)
|
||||
|
||||
set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION ${pathLIBOPENCV_JAVA})
|
||||
|
||||
# Searches for a specified prebuilt library and stores the path as a
|
||||
# variable. Because CMake includes system libraries in the search path by
|
||||
# default, you only need to specify the name of the public NDK library
|
||||
# you want to add. CMake verifies that the library exists before
|
||||
# completing its build.
|
||||
|
||||
find_library( # Sets the name of the path variable.
|
||||
log-lib
|
||||
|
||||
# Specifies the name of the NDK library that
|
||||
# you want CMake to locate.
|
||||
log)
|
||||
|
||||
# Specifies libraries CMake should link to your target library. You
|
||||
# can link multiple libraries, such as libraries you define in this
|
||||
# build script, prebuilt third-party libraries, or system libraries.
|
||||
|
||||
target_link_libraries( # Specifies the target library.
|
||||
native-lib
|
||||
|
||||
lib_opencv
|
||||
|
||||
# Links the target library to the log library
|
||||
# included in the NDK.
|
||||
${log-lib})
|
||||
10
app/src/main/cpp/native-lib.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <jni.h>
|
||||
#include <string>
|
||||
|
||||
extern "C" JNIEXPORT jstring JNICALL
|
||||
Java_com_example_myapplication_MainActivity_stringFromJNI(
|
||||
JNIEnv* env,
|
||||
jobject /* this */) {
|
||||
std::string hello = "Hello from C++";
|
||||
return env->NewStringUTF(hello.c_str());
|
||||
}
|
||||
124
app/src/main/java/com/qtagger/Activity/CameraActivity.java
Normal file
@@ -0,0 +1,124 @@
|
||||
package com.qtagger.Activity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ImageFormat;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.hardware.Camera;
|
||||
import android.os.Bundle;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.qtagger.CustomPalette.CameraSurfaceView;
|
||||
import com.qtagger.R;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
public class CameraActivity extends AppCompatActivity {
|
||||
ImageView imageView;
|
||||
CameraSurfaceView surfaceView;
|
||||
public boolean previewing = false;;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_camera);
|
||||
|
||||
|
||||
imageView = findViewById(R.id.imageView);
|
||||
surfaceView = findViewById(R.id.surfaceView);
|
||||
|
||||
Button button = findViewById(R.id.button);
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
capture();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void viewToggle(){
|
||||
if(imageView.getVisibility() == View.GONE)
|
||||
{
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
surfaceView.setVisibility(View.GONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
imageView.setVisibility(View.GONE);
|
||||
surfaceView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void capture(){
|
||||
surfaceView.capture(new Camera.PictureCallback() {
|
||||
@Override
|
||||
public void onPictureTaken(byte[] data, Camera camera) {
|
||||
//bytearray 형식으로 전달
|
||||
//이걸이용해서 이미지뷰로 보여주거나 파일로 저장
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
//options.inSampleSize = 8; // 1/8사이즈로 보여주기
|
||||
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length); //data 어레이 안에 있는 데이터 불러와서 비트맵에 저장
|
||||
|
||||
|
||||
int width = bitmap.getWidth();
|
||||
int height = bitmap.getHeight();
|
||||
int newWidth = 200;
|
||||
int newHeight = 200;
|
||||
|
||||
float scaleWidth = ((float) newWidth) / width;
|
||||
float scaleHeight = ((float) newHeight) / height;
|
||||
|
||||
Matrix matrix = new Matrix();
|
||||
|
||||
matrix.postScale(scaleWidth, scaleHeight);
|
||||
|
||||
matrix.postRotate(90);
|
||||
|
||||
|
||||
|
||||
Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0,0,width,height,matrix,true);
|
||||
Date currentTime = Calendar.getInstance().getTime();
|
||||
String time = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.getDefault()).format(currentTime);
|
||||
Canvas cs = new Canvas(resizedBitmap);
|
||||
|
||||
|
||||
Paint tPaint = new Paint();
|
||||
tPaint.setTextSize(10);
|
||||
tPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
|
||||
tPaint.setColor(Color.BLACK);
|
||||
tPaint.setStyle(Paint.Style.FILL);
|
||||
cs.drawText("TOP - FRONT",10f,20f,tPaint);
|
||||
cs.drawText(time,10f,10+20f,tPaint);
|
||||
cs.drawText("K042022B000009",10f,20+20f,tPaint);
|
||||
|
||||
|
||||
BitmapDrawable bmd = new BitmapDrawable(resizedBitmap);
|
||||
imageView.setImageDrawable(new BitmapDrawable(resizedBitmap));//이미지뷰에 사진 보여주기
|
||||
camera.startPreview();
|
||||
viewToggle();
|
||||
}
|
||||
});
|
||||
|
||||
//viewToggle();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
167
app/src/main/java/com/qtagger/Activity/MoreActivity.java
Normal file
@@ -0,0 +1,167 @@
|
||||
package com.qtagger.Activity;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.qtagger.Data.TestEnum;
|
||||
import com.qtagger.R;
|
||||
import com.qtagger.util.DataManager;
|
||||
import com.qtagger.util.OracleQueryStr;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MoreActivity extends AppCompatActivity {
|
||||
|
||||
|
||||
private DataManager dataManager = DataManager.getInstance();
|
||||
private TestEnum syncTestEnum = TestEnum.선택안함;
|
||||
private String[] testEnumKeys = TestEnum.getKeyNames();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_more);
|
||||
|
||||
findViewById(R.id.imageFilterButton_Back).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.Item_DBSync).setOnClickListener(new View.OnClickListener() {
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
new AlertDialog.Builder(MoreActivity.this).setTitle("검사 단계 선택").setSingleChoiceItems(testEnumKeys, -1, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
syncTestEnum = TestEnum.getByName(testEnumKeys[which]);
|
||||
}
|
||||
}).setPositiveButton("확인", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if(syncTestEnum != TestEnum.선택안함) {
|
||||
Intent intent = new Intent(getApplicationContext(), SyncActivity.class);
|
||||
intent.putExtra("TestEnumLabel", syncTestEnum.label());
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
}).setNegativeButton("취소", null).show();
|
||||
//테스트
|
||||
|
||||
/*
|
||||
syncTestEnum = TestEnum.발생지특성검사;
|
||||
|
||||
Intent intent = new Intent(getApplicationContext(), SyncActivity.class);
|
||||
intent.putExtra("TestEnumLabel",syncTestEnum.label());
|
||||
startActivity(intent);*/
|
||||
|
||||
//intent.putExtra("boolean",false);
|
||||
|
||||
//데이터 가져오기
|
||||
/*
|
||||
new Thread(() ->{
|
||||
OracleGet(TestEnum.발생지특성검사);
|
||||
OracleGet(TestEnum.인수검사);
|
||||
OracleGet(TestEnum.예비검사);
|
||||
OracleGet(TestEnum.처분검사);
|
||||
}).start();*/
|
||||
}
|
||||
});
|
||||
|
||||
TextView textViewId = findViewById(R.id.TextView_Id);
|
||||
TextView textViewName = findViewById(R.id.TextView_Name);
|
||||
|
||||
textViewId.setText(dataManager.loginAccount.getAccountId());
|
||||
textViewName.setText(dataManager.loginAccount.getAccountName());
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
private void OracleGet(TestEnum testEnum){
|
||||
if(testEnum == TestEnum.선택안함)
|
||||
return;
|
||||
|
||||
Connection conn = null;
|
||||
PreparedStatement psmt = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
String url = "jdbc:oracle:thin:@1.245.98.188:1521:orcl";
|
||||
String id = "optima_admin";
|
||||
String pw = "optima_admin";
|
||||
try {
|
||||
// 3. JDBC 드라이버 로딩
|
||||
Class.forName("oracle.jdbc.driver.OracleDriver");
|
||||
|
||||
// 4. 접속
|
||||
// - Connection 객체 생성 + 접속 작업.
|
||||
conn = DriverManager.getConnection(url, id, pw);
|
||||
|
||||
// 5. SQL
|
||||
String sql = OracleQueryStr.GetEnumQuery(testEnum);
|
||||
|
||||
psmt = conn.prepareStatement(sql);
|
||||
rs = psmt.executeQuery();
|
||||
if(rs != null) {
|
||||
|
||||
ResultSetMetaData rsmd = rs.getMetaData();
|
||||
int columnCount = rsmd.getColumnCount();
|
||||
List<String> columnList = new ArrayList<>();
|
||||
String insertTitle = "";
|
||||
|
||||
for(int i=1; i<=columnCount; i++) {
|
||||
String checkStr = rsmd.getColumnName(i);
|
||||
if(!checkStr.equals("MAX_REVISION")) {
|
||||
columnList.add(checkStr);
|
||||
}
|
||||
}
|
||||
|
||||
insertTitle = "INSERT or REPLACE INTO "+testEnum.label()+" ("+String.join("," ,columnList) + ") VALUES(";
|
||||
|
||||
while (rs.next()) {
|
||||
|
||||
|
||||
List<String> valueList = new ArrayList<>();
|
||||
for (String title:
|
||||
columnList) {
|
||||
String value = rs.getString(title);
|
||||
if(value == null) {
|
||||
valueList.add(rs.getString(title));
|
||||
}
|
||||
else
|
||||
{
|
||||
valueList.add("'"+rs.getString(title)+"'");
|
||||
}
|
||||
|
||||
}
|
||||
String insertSql = insertTitle + String.join(",",valueList) + ")";
|
||||
dataManager.dbHelper.insertQuery(insertSql);
|
||||
}
|
||||
}
|
||||
// 6. 접속종료
|
||||
conn.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,14 @@ public class SearchActivity extends AppCompatActivity {
|
||||
getSupportFragmentManager().beginTransaction().add(R.id.frame,rfidFragment).commit();
|
||||
tabs = (TabLayout) findViewById(R.id.tabs);
|
||||
|
||||
findViewById(R.id.imageFilterButton_Setting).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getApplicationContext(), MoreActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
tabs.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
@Override
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
|
||||
325
app/src/main/java/com/qtagger/Activity/SyncActivity.java
Normal file
@@ -0,0 +1,325 @@
|
||||
package com.qtagger.Activity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SearchView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.qtagger.CustomPalette.CheckableListViewAdapter;
|
||||
import com.qtagger.Data.PkgNoCheck;
|
||||
import com.qtagger.Data.TestEnum;
|
||||
import com.qtagger.Database.PKG;
|
||||
import com.qtagger.R;
|
||||
import com.qtagger.util.DataManager;
|
||||
import com.qtagger.util.OracleQueryStr;
|
||||
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
public class SyncActivity extends AppCompatActivity {
|
||||
private DataManager dataManager = DataManager.getInstance();
|
||||
private TestEnum syncTestEnum = TestEnum.선택안함;
|
||||
List<PkgNoCheck> PkgNoList = new ArrayList<>();
|
||||
ListView listPkg;
|
||||
SearchView searchView;
|
||||
CheckableListViewAdapter adapter = new CheckableListViewAdapter();
|
||||
SparseBooleanArray checkbool;
|
||||
List<PKG> pkgList;
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_sync);
|
||||
|
||||
Intent intent = getIntent();
|
||||
syncTestEnum = TestEnum.getByLabel(intent.getStringExtra("TestEnumLabel"));
|
||||
((TextView) findViewById(R.id.textViewTestType)).setText(syncTestEnum.getKey());
|
||||
pkgList = dataManager.dbHelper.getAllTest(syncTestEnum);
|
||||
Thread oracleData = new Thread(() ->{
|
||||
OracleGet(syncTestEnum);
|
||||
});
|
||||
oracleData.start();
|
||||
try {
|
||||
oracleData.join();
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
listPkg = findViewById(R.id.list_pkg);
|
||||
|
||||
for (PkgNoCheck pkg: PkgNoList ) {
|
||||
adapter.addItem(pkg.getPkgNo());
|
||||
}
|
||||
listPkg.setAdapter(adapter);
|
||||
|
||||
for (int i=0;i<adapter.getCount();i++)
|
||||
{
|
||||
listPkg.setItemChecked(i,true);
|
||||
}
|
||||
|
||||
findViewById(R.id.button_Download).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ProgressDialog progressDialog = new ProgressDialog(SyncActivity.this);
|
||||
progressDialog.setMessage("다운로드 중입니다.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.setProgressStyle(android.R.style.Widget_ProgressBar_Horizontal);
|
||||
progressDialog.show();
|
||||
//해당 번호에 대한 데이터 다운로드
|
||||
checkbool = listPkg.getCheckedItemPositions();
|
||||
List<String> checkedList = new ArrayList<>();
|
||||
for (int i=0;i<adapter.getCount();i++)
|
||||
{
|
||||
String adapterStr = adapter.getItem(i);
|
||||
boolean check = checkbool.get(i);
|
||||
if(check)
|
||||
checkedList.add(adapterStr);
|
||||
}
|
||||
Thread downloadThread = new Thread(() ->{
|
||||
OracleGet(syncTestEnum,checkedList);
|
||||
progressDialog.dismiss();
|
||||
finish();
|
||||
});
|
||||
downloadThread.start();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
findViewById(R.id.imageFilterButton_Back).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
searchView = findViewById(R.id.searchViewPkg);
|
||||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
// Do whatever you need. This will be fired only when submitting.
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
// Do whatever you need when text changes.
|
||||
// This will be fired every time you input any character.
|
||||
checkbool = listPkg.getCheckedItemPositions();
|
||||
List<String> checkedList = new ArrayList<>();
|
||||
for (int i=0;i<adapter.getCount();i++)
|
||||
{
|
||||
String adapterStr = adapter.getItem(i);
|
||||
boolean check = checkbool.get(i);
|
||||
if(check)
|
||||
checkedList.add(adapterStr);
|
||||
}
|
||||
|
||||
for (PkgNoCheck pcheck:PkgNoList) {
|
||||
boolean checked = false;
|
||||
for (String check2:checkedList) {
|
||||
if(pcheck.getPkgNo().compareTo(check2) == 0)
|
||||
{
|
||||
checked =true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
pcheck.setCheck(checked);
|
||||
}
|
||||
|
||||
|
||||
|
||||
adapter.clear();
|
||||
if(newText.length() != 0) {
|
||||
for (PkgNoCheck pkg: PkgNoList ) {
|
||||
if(pkg.getPkgNo().toLowerCase().contains(newText.toLowerCase()))
|
||||
{
|
||||
adapter.addItem(pkg.getPkgNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (PkgNoCheck pkg: PkgNoList ) {
|
||||
adapter.addItem(pkg.getPkgNo());
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0;i<adapter.getCount();i++)
|
||||
{
|
||||
String adapterStr = adapter.getItem(i);
|
||||
boolean defaultCheck = false;
|
||||
for (String pkg: checkedList ) {
|
||||
if(pkg.compareTo(adapterStr) == 0)
|
||||
{
|
||||
defaultCheck = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
listPkg.setItemChecked(i,defaultCheck);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
private void OracleGet(TestEnum testEnum){
|
||||
if(testEnum == TestEnum.선택안함)
|
||||
return;
|
||||
|
||||
Connection conn = null;
|
||||
PreparedStatement psmt = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
String url = "jdbc:oracle:thin:@1.245.98.188:1521:orcl";
|
||||
String id = "optima_admin";
|
||||
String pw = "optima_admin";
|
||||
try {
|
||||
// 3. JDBC 드라이버 로딩
|
||||
Class.forName("oracle.jdbc.driver.OracleDriver");
|
||||
|
||||
// 4. 접속
|
||||
// - Connection 객체 생성 + 접속 작업.
|
||||
conn = DriverManager.getConnection(url, id, pw);
|
||||
|
||||
// 5. SQL
|
||||
String sql = OracleQueryStr.GetPkgNoListQuery(testEnum);
|
||||
|
||||
psmt = conn.prepareStatement(sql);
|
||||
rs = psmt.executeQuery();
|
||||
if(rs != null) {
|
||||
while (rs.next())
|
||||
{
|
||||
String dbPkgNoStr = rs.getString("PKG_NO");
|
||||
boolean includeChecker = true;
|
||||
for (PKG pkg:pkgList
|
||||
) {
|
||||
if(pkg.getPKG_NO().compareTo(dbPkgNoStr) == 0)
|
||||
{
|
||||
includeChecker = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(includeChecker) {
|
||||
PkgNoList.add(new PkgNoCheck(dbPkgNoStr, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
// 6. 접속종료
|
||||
conn.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
private void OracleGet(TestEnum testEnum ,List<String> whiteList){
|
||||
if(testEnum == TestEnum.선택안함)
|
||||
return;
|
||||
|
||||
Connection conn = null;
|
||||
PreparedStatement psmt = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
String url = "jdbc:oracle:thin:@1.245.98.188:1521:orcl";
|
||||
String id = "optima_admin";
|
||||
String pw = "optima_admin";
|
||||
try {
|
||||
// 3. JDBC 드라이버 로딩
|
||||
Class.forName("oracle.jdbc.driver.OracleDriver");
|
||||
|
||||
// 4. 접속
|
||||
// - Connection 객체 생성 + 접속 작업.
|
||||
conn = DriverManager.getConnection(url, id, pw);
|
||||
|
||||
// 5. SQL
|
||||
String sql = OracleQueryStr.GetEnumQuery(testEnum);
|
||||
|
||||
psmt = conn.prepareStatement(sql);
|
||||
rs = psmt.executeQuery();
|
||||
if(rs != null) {
|
||||
|
||||
ResultSetMetaData rsmd = rs.getMetaData();
|
||||
int columnCount = rsmd.getColumnCount();
|
||||
List<String> columnList = new ArrayList<>();
|
||||
String insertTitle = "";
|
||||
|
||||
for(int i=1; i<=columnCount; i++) {
|
||||
String checkStr = rsmd.getColumnName(i);
|
||||
if(!checkStr.equals("MAX_REVISION")) {
|
||||
columnList.add(checkStr);
|
||||
}
|
||||
}
|
||||
|
||||
insertTitle = "INSERT or REPLACE INTO "+testEnum.label()+" ("+String.join("," ,columnList) + ") VALUES(";
|
||||
|
||||
while (rs.next()) {
|
||||
String dbPkgNo = rs.getString("PKG_NO");
|
||||
boolean skip = true;
|
||||
for (String white:
|
||||
whiteList) {
|
||||
if(dbPkgNo.compareTo(white) == 0)
|
||||
{
|
||||
skip = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(skip)
|
||||
continue;
|
||||
|
||||
List<String> valueList = new ArrayList<>();
|
||||
for (String title:
|
||||
columnList) {
|
||||
String value = rs.getString(title);
|
||||
if(value == null) {
|
||||
valueList.add(rs.getString(title));
|
||||
}
|
||||
else
|
||||
{
|
||||
valueList.add("'"+rs.getString(title)+"'");
|
||||
}
|
||||
|
||||
}
|
||||
String insertSql = insertTitle + String.join(",",valueList) + ")";
|
||||
dataManager.dbHelper.insertQuery(insertSql);
|
||||
}
|
||||
}
|
||||
// 6. 접속종료
|
||||
conn.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,14 @@ public class TestActivity extends AppCompatActivity {
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.imageFilterButton_Setting).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getApplicationContext(), MoreActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//기본 탭 세팅
|
||||
getSupportFragmentManager().beginTransaction().add(R.id.frame,surfaceFragment).commit();
|
||||
|
||||
@@ -95,5 +95,13 @@ public class TestSelectActivity extends AppCompatActivity {
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.imageFilterButton_Setting).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getApplicationContext(), MoreActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.qtagger.CustomPalette;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.ImageFormat;
|
||||
import android.hardware.Camera;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
|
||||
public class CameraSurfaceView extends SurfaceView implements SurfaceHolder.Callback{
|
||||
SurfaceHolder holder;
|
||||
Camera camera = null;
|
||||
public CameraSurfaceView(Context context) {
|
||||
super(context);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public CameraSurfaceView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context);
|
||||
}
|
||||
|
||||
private void init(Context context){
|
||||
//초기화를 위한 메소드
|
||||
holder = getHolder();
|
||||
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
|
||||
holder.addCallback(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceCreated(SurfaceHolder surfaceHolder) {
|
||||
//만들어지는시점
|
||||
camera = Camera.open();//카메라 객체 참조
|
||||
try{
|
||||
// TODO : 파라미터 옵션은 QTagger에서 다시 한번 확인할 것
|
||||
Camera.Parameters mParams = camera.getParameters();
|
||||
mParams.setPreviewFpsRange(15000, 30000);
|
||||
|
||||
//mParams.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
|
||||
mParams.setPreviewFormat(ImageFormat.NV21);
|
||||
mParams.setPreviewFrameRate(30);
|
||||
camera.setParameters(mParams);
|
||||
|
||||
camera.setPreviewDisplay(holder);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) {
|
||||
//변경
|
||||
camera.startPreview(); //렌즈로 부터 들어오는 영상을 뿌려줌
|
||||
camera.stopPreview();
|
||||
camera.setDisplayOrientation(90);//카메라 미리보기 오른쪽 으로 90 도회전
|
||||
camera.startPreview();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
|
||||
//소멸
|
||||
camera.stopPreview();//미리보기중지
|
||||
camera.release();
|
||||
camera = null;
|
||||
}
|
||||
|
||||
public boolean capture(Camera.PictureCallback callback){
|
||||
if(camera != null){
|
||||
camera.takePicture(null,null,callback);
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.qtagger.CustomPalette;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.Checkable;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.qtagger.R;
|
||||
|
||||
public class CheckableLinearLayout extends LinearLayout implements Checkable {
|
||||
public CheckableLinearLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
// mIsChecked = false ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
|
||||
CheckBox cb = (CheckBox) findViewById(R.id.checkBox1) ;
|
||||
|
||||
return cb.isChecked() ;
|
||||
// return mIsChecked ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggle() {
|
||||
CheckBox cb = (CheckBox) findViewById(R.id.checkBox1) ;
|
||||
|
||||
setChecked(cb.isChecked() ? false : true) ;
|
||||
// setChecked(mIsChecked ? false : true) ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChecked(boolean checked) {
|
||||
CheckBox cb = (CheckBox) findViewById(R.id.checkBox1) ;
|
||||
|
||||
if (cb.isChecked() != checked) {
|
||||
cb.setChecked(checked) ;
|
||||
}
|
||||
|
||||
// CheckBox 가 아닌 View의 상태 변경.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.qtagger.CustomPalette;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.qtagger.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CheckableListViewAdapter extends BaseAdapter {
|
||||
private ArrayList<String> listViewItemList = new ArrayList<String>() ;
|
||||
|
||||
public CheckableListViewAdapter(){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return listViewItemList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItem(int position) {
|
||||
return listViewItemList.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void clear(){
|
||||
listViewItemList.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View view, ViewGroup parent) {
|
||||
final int pos = position;
|
||||
final Context context = parent.getContext();
|
||||
|
||||
// "listview_item" Layout을 inflate하여 convertView 참조 획득.
|
||||
if (view == null) {
|
||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = inflater.inflate(R.layout.listview_item, parent, false);
|
||||
}
|
||||
TextView textTextView = (TextView) view.findViewById(R.id.textView1) ;
|
||||
|
||||
// Data Set(listViewItemList)에서 position에 위치한 데이터 참조 획득
|
||||
String listViewItem = listViewItemList.get(position);
|
||||
textTextView.setText(listViewItem);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
public void addItem(String text) {
|
||||
listViewItemList.add(text);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
27
app/src/main/java/com/qtagger/Data/PkgNoCheck.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.qtagger.Data;
|
||||
|
||||
public class PkgNoCheck {
|
||||
String PkgNo;
|
||||
boolean check;
|
||||
|
||||
public PkgNoCheck(String pkgNo, boolean check) {
|
||||
PkgNo = pkgNo;
|
||||
this.check = check;
|
||||
}
|
||||
|
||||
public String getPkgNo() {
|
||||
return PkgNo;
|
||||
}
|
||||
|
||||
public void setPkgNo(String pkgNo) {
|
||||
PkgNo = pkgNo;
|
||||
}
|
||||
|
||||
public boolean isCheck() {
|
||||
return check;
|
||||
}
|
||||
|
||||
public void setCheck(boolean check) {
|
||||
this.check = check;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,43 @@
|
||||
package com.qtagger.Data;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public enum TestEnum {
|
||||
선택안함("NoSelect"),발생지특성검사("ORIGIN_CHRCT"),예비검사("PREPAR_TEST"),인수검사("ACCEPT_TEST"),처분검사("DISPOSAL_TEST");
|
||||
private final String label;
|
||||
|
||||
public static TestEnum getByName(String Name)
|
||||
{
|
||||
|
||||
if(Name.compareTo(발생지특성검사.name()) == 0)
|
||||
return 발생지특성검사;
|
||||
else if(Name.compareTo(예비검사.name()) == 0)
|
||||
return 예비검사;
|
||||
else if(Name.compareTo(인수검사.name()) == 0)
|
||||
return 인수검사;
|
||||
else if(Name.compareTo(처분검사.name()) == 0)
|
||||
return 처분검사;
|
||||
|
||||
return 선택안함;
|
||||
}
|
||||
|
||||
public static TestEnum getByLabel(String Label)
|
||||
{
|
||||
|
||||
if(Label.compareTo(발생지특성검사.label) == 0)
|
||||
return 발생지특성검사;
|
||||
else if(Label.compareTo(예비검사.label) == 0)
|
||||
return 예비검사;
|
||||
else if(Label.compareTo(인수검사.label) == 0)
|
||||
return 인수검사;
|
||||
else if(Label.compareTo(처분검사.label) == 0)
|
||||
return 처분검사;
|
||||
|
||||
return 선택안함;
|
||||
}
|
||||
|
||||
TestEnum(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
@@ -11,4 +45,26 @@ public enum TestEnum {
|
||||
public String label() {
|
||||
return label;
|
||||
}
|
||||
public String getKey() {
|
||||
return name();
|
||||
}
|
||||
|
||||
|
||||
public static List<String> getKeyNameList(boolean selectChecker)
|
||||
{
|
||||
List<String> keys = new ArrayList<>();
|
||||
if(selectChecker) {
|
||||
keys.add("선택안함");
|
||||
}
|
||||
keys.add("발생지특성검사");
|
||||
keys.add("예비검사");
|
||||
keys.add("인수검사");
|
||||
keys.add("처분검사");
|
||||
|
||||
return keys;
|
||||
}
|
||||
public static String[] getKeyNames()
|
||||
{
|
||||
return new String[] {"발생지특성검사", "예비검사", "인수검사", "처분검사"};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
import com.qtagger.Data.TestEnum;
|
||||
import com.qtagger.util.CommonHelper;
|
||||
|
||||
import java.io.File;
|
||||
@@ -105,6 +106,21 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||
return resultData;
|
||||
}
|
||||
|
||||
public List<PKG> getAllTest(TestEnum testEnum)
|
||||
{
|
||||
if(testEnum == TestEnum.발생지특성검사)
|
||||
return getAllORIGIN_CHRCT();
|
||||
else if(testEnum == TestEnum.예비검사)
|
||||
return getAllPREPAR_TEST();
|
||||
else if(testEnum == TestEnum.처분검사)
|
||||
return getAllDISPOSAL_TEST();
|
||||
else if(testEnum == TestEnum.인수검사)
|
||||
return getAllACCEPT_TEST();
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public List<AccountData> getAllAccount(){
|
||||
List<AccountData> resultData = new ArrayList<AccountData>();
|
||||
|
||||
@@ -19,6 +19,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.qtagger.Activity.AccountAdd;
|
||||
import com.qtagger.Activity.AccountList;
|
||||
import com.qtagger.Activity.CameraActivity;
|
||||
import com.qtagger.Activity.NavigationActivity;
|
||||
import com.qtagger.Activity.TestSelectActivity;
|
||||
import com.qtagger.Database.AccountData;
|
||||
@@ -79,7 +80,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
//테스트용도 나중에 삭제
|
||||
findViewById(R.id.imageView).setOnClickListener(v -> {
|
||||
Intent intent = new Intent(getApplicationContext(), test.class);
|
||||
Intent intent = new Intent(getApplicationContext(), CameraActivity.class);
|
||||
startActivity(intent);
|
||||
|
||||
});
|
||||
|
||||
@@ -7,25 +7,44 @@ import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.res.AssetManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.googlecode.tesseract.android.TessBaseAPI;
|
||||
import com.qtagger.Activity.SyncActivity;
|
||||
import com.qtagger.Data.TestEnum;
|
||||
import com.qtagger.Database.PKG;
|
||||
import com.qtagger.util.DataManager;
|
||||
import com.qtagger.util.OracleQueryStr;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.opencv.android.OpenCVLoader;
|
||||
import org.opencv.android.Utils;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.imgproc.Imgproc;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.ConnectException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
@@ -40,7 +59,11 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class test extends AppCompatActivity {
|
||||
ListView list1;
|
||||
ImageView imageView;
|
||||
private DataManager dataManager;
|
||||
TessBaseAPI tessBaseAPI;
|
||||
ProgressDialog progressDialog;
|
||||
@SuppressLint("WrongThread")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -49,6 +72,32 @@ public class test extends AppCompatActivity {
|
||||
list1 = findViewById(R.id.list_test);
|
||||
|
||||
String testString[] = {"A","B","C"};//,"D","E","A","B","C","D","E"};
|
||||
progressDialog = new ProgressDialog(test.this);
|
||||
progressDialog.setMessage("다운로드 중입니다.");
|
||||
progressDialog.setCancelable(true);
|
||||
progressDialog.setProgressStyle(android.R.style.Widget_ProgressBar_Horizontal);
|
||||
|
||||
tessBaseAPI = new TessBaseAPI();
|
||||
String dir = getFilesDir() + "/tesseract";
|
||||
|
||||
if(checkLanguageFile(dir+"/tessdata"))
|
||||
{
|
||||
tessBaseAPI.init(dir, "eng");
|
||||
|
||||
tessBaseAPI.setPageSegMode(TessBaseAPI.PageSegMode.PSM_SINGLE_LINE);
|
||||
tessBaseAPI.setVariable(TessBaseAPI.VAR_CHAR_BLACKLIST, ",!?@#$%&*()<>_-+=/:;'\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
|
||||
tessBaseAPI.setVariable(TessBaseAPI.VAR_CHAR_WHITELIST, "1234567890.");
|
||||
tessBaseAPI.setVariable("classify_bln_numeric_mode", "1");
|
||||
String testImage = "IMG_20220913_060413.jpg";
|
||||
testImage = "weight_test_image.png";
|
||||
testImage = "tesseractTest2.png";
|
||||
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM) +"/Camera/"+ testImage;
|
||||
File file = new File(path);
|
||||
Bitmap myBitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
|
||||
tessBaseAPI.setImage(myBitmap);
|
||||
String resultText = tessBaseAPI.getUTF8Text();
|
||||
Log.i("Tess",resultText);
|
||||
}
|
||||
|
||||
ArrayAdapter<String> aa_items = new ArrayAdapter<String>(this, androidx.appcompat.R.layout.support_simple_spinner_dropdown_item,testString)
|
||||
{
|
||||
@@ -66,20 +115,78 @@ public class test extends AppCompatActivity {
|
||||
};
|
||||
|
||||
list1.setAdapter(aa_items);
|
||||
|
||||
imageView = findViewById(R.id.imageViewTest);
|
||||
|
||||
|
||||
findViewById(R.id.button3).setOnClickListener(new View.OnClickListener() {
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
progressDialog.show();
|
||||
|
||||
new Thread(()->{
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
progressDialog.dismiss();
|
||||
finish();
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
String testImage = "IMG_20220913_060413.jpg";
|
||||
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM) +"/Camera/"+ testImage;
|
||||
File file = new File(path);
|
||||
if(file.exists())
|
||||
{
|
||||
/*
|
||||
Bitmap myBitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
|
||||
imageView.setImageBitmap(myBitmap);
|
||||
new AsyncTess().execute(myBitmap);*/
|
||||
//imageView.capture(new )
|
||||
|
||||
/*
|
||||
new Thread(() ->{
|
||||
Bitmap myBitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
|
||||
|
||||
myBitmap = getGrayscale(myBitmap);
|
||||
Bitmap finalMyBitmap = myBitmap;
|
||||
imageView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
imageView.setImageBitmap(finalMyBitmap);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}).start();*/
|
||||
|
||||
//Bitmap myBitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
|
||||
|
||||
//getGrayscale(myBitmap);
|
||||
|
||||
//imageView.setImageBitmap(myBitmap);
|
||||
}
|
||||
//Bitmap bmp = new Bitmap
|
||||
|
||||
|
||||
/*
|
||||
if(OpenCVLoader.initDebug())
|
||||
{
|
||||
Log.d("Opencv_Log","Init");
|
||||
Mat src = new Mat();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
new Thread(() ->{
|
||||
OracleGet(TestEnum.발생지특성검사);
|
||||
OracleGet(TestEnum.인수검사);
|
||||
OracleGet(TestEnum.예비검사);
|
||||
OracleGet(TestEnum.처분검사);
|
||||
}).start();
|
||||
}).start();*/
|
||||
|
||||
|
||||
//HttpGet();
|
||||
@@ -97,7 +204,78 @@ public class test extends AppCompatActivity {
|
||||
}*/
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private class AsyncTess extends AsyncTask<Bitmap, Integer, String> {
|
||||
@Override
|
||||
protected String doInBackground(Bitmap... mRelativeParams) {
|
||||
tessBaseAPI.setImage(mRelativeParams[0]);
|
||||
return tessBaseAPI.getUTF8Text();
|
||||
}
|
||||
|
||||
protected void onPostExecute(String result) {
|
||||
|
||||
result.toLowerCase();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
boolean checkLanguageFile(String dir)
|
||||
{
|
||||
File file = new File(dir);
|
||||
if(!file.exists() && file.mkdirs())
|
||||
createFiles(dir);
|
||||
else if(file.exists()){
|
||||
String filePath = dir + "/eng.traineddata";
|
||||
File langDataFile = new File(filePath);
|
||||
if(!langDataFile.exists())
|
||||
createFiles(dir);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void createFiles(String dir)
|
||||
{
|
||||
AssetManager assetMgr = this.getAssets();
|
||||
|
||||
InputStream inputStream = null;
|
||||
OutputStream outputStream = null;
|
||||
|
||||
try {
|
||||
inputStream = assetMgr.open("eng.traineddata");
|
||||
|
||||
String destFile = dir + "/eng.traineddata";
|
||||
|
||||
outputStream = new FileOutputStream(destFile);
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
int read;
|
||||
while ((read = inputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, read);
|
||||
}
|
||||
inputStream.close();
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
}catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Bitmap getGrayscale(Bitmap bitmap){
|
||||
Bitmap result = bitmap.copy(bitmap.getConfig(), true);
|
||||
|
||||
Mat src = new Mat();
|
||||
Mat gray = new Mat();
|
||||
Utils.bitmapToMat(result, src);
|
||||
|
||||
//그레이스케일
|
||||
Imgproc.cvtColor(src, gray, Imgproc.COLOR_BGR2GRAY);
|
||||
Utils.matToBitmap(gray, result);
|
||||
|
||||
src.release();
|
||||
gray.release();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
|
||||
@@ -326,4 +326,22 @@ public class OracleQueryStr {
|
||||
|
||||
}
|
||||
|
||||
public static String GetPkgNoListQuery(TestEnum testEnum)
|
||||
{
|
||||
return "SELECT\n" +
|
||||
" *\n" +
|
||||
"FROM\n" +
|
||||
" (\n" +
|
||||
" SELECT\n" +
|
||||
" PKG_NO,\n" +
|
||||
" ROW_NUMBER() OVER(PARTITION BY FORM_CODE, PKG_NO ORDER BY REVISION DESC) MAX_REVISION\n" +
|
||||
" FROM OPTIMA_ADMIN.TB_MASTER\n" +
|
||||
" WHERE FORM_CODE = '"+testEnum.label()+"'\n" +
|
||||
" AND IS_DELETE = 'N'\n" +
|
||||
" )\n" +
|
||||
"WHERE\n" +
|
||||
" MAX_REVISION = 1";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
15
app/src/main/res/drawable/button_list_background.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<!-- #f5f5f5" 색으로 채움 -->
|
||||
<solid
|
||||
android:color="#FFFFFF"/>
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:bottom="10dp"
|
||||
android:right="10dp"
|
||||
android:top="10dp"
|
||||
/>
|
||||
|
||||
</shape>
|
||||
BIN
app/src/main/res/drawable/download_32.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/drawable/sync_button_32.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
app/src/main/res/drawable/user_account_icon_32.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
30
app/src/main/res/layout/activity_camera.xml
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".Activity.CameraActivity">
|
||||
|
||||
<com.qtagger.CustomPalette.CameraSurfaceView
|
||||
android:id="@+id/surfaceView"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"/>
|
||||
<ImageView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:id="@+id/imageView"
|
||||
android:visibility="gone"
|
||||
android:layout_gravity="center"/>
|
||||
<android.widget.Button
|
||||
android:id="@+id/button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:background="@drawable/button_normal_background"
|
||||
android:text="촬영"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</LinearLayout>
|
||||
99
app/src/main/res/layout/activity_more.xml
Normal file
@@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".Activity.MoreActivity">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<androidx.constraintlayout.utils.widget.ImageFilterButton
|
||||
android:id="@+id/imageFilterButton_Back"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#FFFFFF"
|
||||
android:minWidth="48dp"
|
||||
android:minHeight="48dp"
|
||||
android:src="@drawable/back_arrow_5821"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewRadiation"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="설정"
|
||||
android:textAlignment="center"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<View
|
||||
android:id="@+id/view2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="60dp"
|
||||
android:background="#000000"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="10dp"
|
||||
>
|
||||
<ImageView
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:src="@drawable/user_account_icon_32"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:id="@+id/TextView_Id"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="32dp"
|
||||
android:textSize="20sp"
|
||||
android:gravity="left|center"
|
||||
android:text="계정"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/TextView_Name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16sp"
|
||||
android:text="이름"
|
||||
/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<android.widget.Button
|
||||
android:id="@+id/Item_DBSync"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawableLeft="@drawable/sync_button_32"
|
||||
android:background="@drawable/button_list_background"
|
||||
android:paddingLeft="10dp"
|
||||
android:text=" 동기화"
|
||||
android:gravity="left|center"
|
||||
android:textSize="20sp"
|
||||
android:layout_gravity="left"
|
||||
/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
83
app/src/main/res/layout/activity_sync.xml
Normal file
@@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".Activity.SyncActivity">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<androidx.constraintlayout.utils.widget.ImageFilterButton
|
||||
android:id="@+id/imageFilterButton_Back"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#FFFFFF"
|
||||
android:minWidth="48dp"
|
||||
android:minHeight="48dp"
|
||||
android:src="@drawable/back_arrow_5821"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewTestType"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="검사단계"
|
||||
android:textAlignment="center"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<View
|
||||
android:id="@+id/view2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="60dp"
|
||||
android:background="#000000"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<SearchView
|
||||
android:id="@+id/searchViewPkg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="37dp"
|
||||
android:layout_margin="10dp"
|
||||
|
||||
android:background="@drawable/searchview_background"
|
||||
android:iconifiedByDefault="true"
|
||||
android:paddingLeft="0dp"
|
||||
android:queryHint="방폐물 검색"
|
||||
app:defaultQueryHint="방폐물 검색"
|
||||
app:iconifiedByDefault="false"
|
||||
android:layout_weight="12"/>
|
||||
<ImageButton
|
||||
android:id="@+id/button_Download"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:src="@drawable/download_32"
|
||||
android:background="@android:color/transparent"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<ListView
|
||||
android:id="@+id/list_pkg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:choiceMode="multipleChoice"
|
||||
/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
<ListView
|
||||
android:id="@+id/list_test"
|
||||
android:visibility="gone"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="400dp"
|
||||
android:layout_marginStart="20dp"
|
||||
@@ -52,4 +53,13 @@
|
||||
|
||||
</ListView>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageViewTest"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="400dp"
|
||||
android:layout_marginTop="100dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
27
app/src/main/res/layout/listview_item.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.qtagger.CustomPalette.CheckableLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="horizontal" android:layout_width="match_parent"
|
||||
android:layout_height="30dp"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
tools:ignore="MissingClass">
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/checkBox1"
|
||||
android:focusable="false"
|
||||
android:clickable="false"
|
||||
android:checked="true"
|
||||
android:layout_weight="1" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="TEXT"
|
||||
android:id="@+id/textView1"
|
||||
android:textSize="20sp"
|
||||
android:gravity="left|center"
|
||||
android:layout_weight="12" />
|
||||
|
||||
|
||||
|
||||
</com.qtagger.CustomPalette.CheckableLinearLayout>
|
||||