Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
CHILD INTELLIGENT ASSESSMENT TOOL
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2020-046
CHILD INTELLIGENT ASSESSMENT TOOL
Commits
d515d49a
Commit
d515d49a
authored
Nov 05, 2020
by
Buwaneka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add TakeImage.java
parent
c886385b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
166 additions
and
0 deletions
+166
-0
Count/TakeImage.java
Count/TakeImage.java
+166
-0
No files found.
Count/TakeImage.java
0 → 100644
View file @
d515d49a
package
com.example.count
;
import
android.app.Activity
;
import
android.app.Dialog
;
import
android.content.ContextWrapper
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.graphics.Bitmap
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.os.Environment
;
import
android.provider.MediaStore
;
import
android.util.Log
;
import
android.view.View
;
import
android.view.Window
;
import
android.widget.Button
;
import
android.widget.ImageView
;
import
android.widget.ProgressBar
;
import
android.widget.Toast
;
import
com.theartofdev.edmodo.cropper.CropImage
;
import
com.theartofdev.edmodo.cropper.CropImageView
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.util.Random
;
public
class
TakeImage
extends
Activity
{
Bitmap
selectedImageB
;
ImageView
image
;
Button
btnconfirm
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
take_image_activity
);
GlobleVariable
.
done
=
false
;
Button
btntake
=
findViewById
(
R
.
id
.
takeimage
);
btnconfirm
=
findViewById
(
R
.
id
.
confirm
);
image
=
findViewById
(
R
.
id
.
image
);
btnconfirm
.
setEnabled
(
false
);
btntake
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
CropImage
.
activity
()
.
setGuidelines
(
CropImageView
.
Guidelines
.
ON
)
.
start
(
TakeImage
.
this
);
}
});
btnconfirm
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Dialog
settingsDialog
=
new
Dialog
(
TakeImage
.
this
);
settingsDialog
.
getWindow
().
requestFeature
(
Window
.
FEATURE_NO_TITLE
);
settingsDialog
.
setContentView
(
getLayoutInflater
().
inflate
(
R
.
layout
.
confirm_layout
,
null
));
settingsDialog
.
show
();
settingsDialog
.
setCanceledOnTouchOutside
(
true
);
Button
confirmed
=
settingsDialog
.
findViewById
(
R
.
id
.
confirmgo
);
confirmed
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
startActivity
(
new
Intent
(
TakeImage
.
this
,
ImageClassification
.
class
));
}
});
}
});
}
@Override
public
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
if
(
requestCode
==
CropImage
.
CROP_IMAGE_ACTIVITY_REQUEST_CODE
)
{
CropImage
.
ActivityResult
result
=
CropImage
.
getActivityResult
(
data
);
if
(
resultCode
==
RESULT_OK
)
{
Uri
resultUri
=
result
.
getUri
();
image
.
setImageURI
(
resultUri
);
try
{
selectedImageB
=
MediaStore
.
Images
.
Media
.
getBitmap
(
this
.
getContentResolver
(),
resultUri
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
else
if
(
resultCode
==
CropImage
.
CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE
)
{
Exception
error
=
result
.
getError
();
}
}
backgrounNumberSeperate
newbackGP
=
new
backgrounNumberSeperate
();
newbackGP
.
start
();
}
class
backgrounNumberSeperate
extends
Thread
{
public
void
run
(){
SeperateNumbers
OseperateNumber
=
new
SeperateNumbers
();
final
ProgressBar
simpleProgressBar
=
(
ProgressBar
)
findViewById
(
R
.
id
.
pb
);
try
{
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
simpleProgressBar
.
setVisibility
(
View
.
VISIBLE
);
}
});
}
catch
(
final
Exception
ex
)
{
Log
.
i
(
"---"
,
"Exception in thread"
);
}
Bitmap
NumberSeperateImage
=
OseperateNumber
.
getResizedBitmap
(
selectedImageB
,
600
);
final
Bitmap
MarkedNumbers
=
OseperateNumber
.
BlackAndWite
(
NumberSeperateImage
);
if
(
GlobleVariable
.
done
){
GlobleVariable
.
bitmapNo
.
add
(
NumberSeperateImage
);
try
{
// code runs in a thread
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
simpleProgressBar
.
setVisibility
(
View
.
INVISIBLE
);
image
.
setImageBitmap
(
MarkedNumbers
);
btnconfirm
.
setEnabled
(
true
);
}
});
}
catch
(
final
Exception
ex
)
{
Log
.
i
(
"---"
,
"Exception in thread"
);
}
}
else
{
try
{
// code runs in a thread
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
Toast
.
makeText
(
getApplicationContext
(),
"TRY AGAIN\n Follow Instructions Above"
,
Toast
.
LENGTH_SHORT
).
show
();
image
.
setImageResource
(
R
.
drawable
.
take
);
simpleProgressBar
.
setVisibility
(
View
.
INVISIBLE
);
btnconfirm
.
setEnabled
(
false
);
}
});
}
catch
(
final
Exception
ex
)
{
Log
.
i
(
"---"
,
"Exception in thread"
);
}
}
}
}
@Override
public
void
onResume
()
{
super
.
onResume
();
}
@Override
public
void
onPause
()
{
super
.
onPause
();
}
@Override
public
void
onDestroy
()
{
super
.
onDestroy
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment