B4A Library RSImageProcessing Library

thedesolatesoul

Expert
Licensed User
Longtime User
The picture I am rotating was taken by the camera, so the actual size is not fully under control.
You could either use the Advanced Camera Lib from Tomas, or you could use Reflection to may be set up the camera resolution.
The reason for rotating is, that the picture taken by the camera in portrait mode, must be rotated before upload in order to display it correctly.
I agree this is a problem. If you do find any solution for this please do post it.
I guess the amount of memory allocated to a process cannot be set by the application, or?
This is set by the OS, so unfortunately no.
 

manios

Active Member
Licensed User
Longtime User
You could either use the Advanced Camera Lib from Tomas, or you could use Reflection to may be set up the camera resolution.


Well setting the resolution is not the main problem, but to what size shall it be set without user intervention? Also this should be done BEFORE the picture is taken. I will try a Try/Catch subroutine to make that automatically.

A second path could be to cut the picture in 2 parts, rotate both parts and put it together again. Anyone have an idea how to do that?
 

vb1992

Well-Known Member
Licensed User
Longtime User
Instagram used 612x612 size and got 20 million users loving it.
Now they offer bigger hi-res sizes.

All depends on what you are trying to achieve.


1936x1936 is now the bigger size they offer
 

mkvidyashankar

Active Member
Licensed User
Longtime User
hi

Yeah, i reduce the image size before processing, it is working fine.
this library is wonderful
n thanks to XverhelstX
 

XverhelstX

Well-Known Member
Licensed User
Longtime User
RSImageProcessing 2!

Library updated heavily to RSImageProcessing 2!

Divided into Filters, Effects and Blending methods.

- 25 blending methods were added (Like photoshop)
- Effects like Paintify, sketchify
- Filters for edge enhancement, gaussian filter, etc
- Improved speed!

And some more methods.

Check out the first post!

tomas
 

mkvidyashankar

Active Member
Licensed User
Longtime User
error in paintify

I tried to use paintify function to bitmap, I am getting the error,

log is here, please chk



java.lang.IllegalArgumentException
at android.view.Surface.unlockCanvasAndPost(Native Method)
at android.view.ViewRoot.draw(ViewRoot.java:1553)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1265)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1867)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
 

JohnC

Expert
Licensed User
Longtime User
What function to use?

If a user takes a picture of a physical paper picture, if the smartphone was not 100% positioned parallel to the paper photo, the image will not be a perfect rectangle - meaning one side of the picture will be shorter (from top to bottom) then the other side.

What image processing function do I need to use to create a more even rectangle image so all corners are 90 degrees?

Thanks for a great lib
 

awama

Active Member
Licensed User
Longtime User
Error with new library 2

Hi,

on my Galaxy S2 , ICS 4.0.3 I got following error with the new library while compiling:

Compiling code. Error
Error compiling program.
Error description: Object reference not set to an instance of an object.
Occurred on line: 20
IO.Initialize("IO")
Word: (

Any idea whats the reason? Thanks.
Walter
 

awama

Active Member
Licensed User
Longtime User
I haven't encountered that error before.
Can you post the log? and unfiltered log? and wrap it in quote tags?

Also are you trying out the sample or not?

Tomas


I am trying the code from the first example with the first library and it works ok, then I replace the library with the new library and then it ist not possible to compile.
I will post the log on sunday.

Walter
 

mkvidyashankar

Active Member
Licensed User
Longtime User
java.lang.ArrayIndexOutOfBoundsException error

I am trying to use image RSImageprocessing library to get sketch effect
my code is like this

B4X:
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.

End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
    Dim io As RSImageProcessing
    Dim ii As RSImageEffects
    Dim ifilter As RSImageFilters
    
    
    Dim panel1 As Panel
    Dim button_sketch As Button
    Dim filedire As String
    Dim bitmap1 As Bitmap
    Dim imageview1 As ImageView
    
End Sub

Sub Activity_Create(FirstTime As Boolean)

  Activity.LoadLayout("layout1")
' If File.IsDirectory(File.DirRootExternal,"/Sketchy/") =False Then
'       File.MakeDir(File.DirRootExternal,"/sketchy/")
'  End If
'      filedire=File.DirRootExternal & "/Sketchy/" 
     
     
     panel1.SetLayout(0,0,100%x,100%y)
     button_sketch.SetLayout(50dip,100%y-40dip,100dip,40dip)
     imageview1.SetLayout(5dip,50dip,100%x-10dip,0.70*100%x)
     ' bitmap1.Initialize(File.DirAssets,"IMG_2436.jpg")
     imageview1.Bitmap = LoadBitmapSample(File.DirAssets,"IMG_2436.jpg",600,480)
     io.Initialize
     
     End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
Sub Button_sketch_Click
    imageview1.Bitmap = ii.Sketchify(LoadBitmapSample(File.DirAssets,"IMG_2436.jpg",600,480),16,0)
   End Sub


I am getting error java.lang.ArrayIndexOutOfBoundsException


** Activity (main) Create, isFirst = true **
RSSketchLibrary has been initialized.
** Activity (main) Resume **
main_button_sketch_click (B4A line: 50)
imageview1.Bitmap = ii.Sketchify(LoadBitmapSample(File.DirAssets,"IMG_2436.jpg",600,480),16,0)
java.lang.ArrayIndexOutOfBoundsException
at com.rootsoft.imageprocessing.ConvolutionMatrix.computeConvolution3x3(ConvolutionMatrix.java:60)
at com.rootsoft.imageprocessing.RSImageEffects.Blur(RSImageEffects.java:87)
at com.rootsoft.imageprocessing.RSImageEffects.Sketchify(RSImageEffects.java:936)
at com.orange.sketch.main._button_sketch_click(main.java:288)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:158)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:154)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:54)
at android.view.View.performClick(View.java:2538)
at android.view.View$PerformClick.run(View.java:9152)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)
java.lang.ArrayIndexOutOfBoundsException
Connected to B4A-Bridge


Where I am erring ?
 

mkvidyashankar

Active Member
Licensed User
Longtime User
Hi

I tried and two steps are successfully done but when it goes to blur method it again gives arrayoutofbounds exception error. i tried for engrave effects also it also gives the same problem. the code was working in the previous library.


Log is here


com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)
java.lang.ArrayIndexOutOfBoundsException
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:com.orange.sketch
** Activity (main) Create, isFirst = true **
RSSketchLibrary has been initialized.
** Activity (main) Resume **
main_button_sketch_click (B4A line: 58)
bitmap2=ii.Engrave(bitmap2)
java.lang.ArrayIndexOutOfBoundsException
at com.rootsoft.imageprocessing.ConvolutionMatrix.computeConvolution3x3(ConvolutionMatrix.java:60)
at com.rootsoft.imageprocessing.RSImageEffects.Engrave(RSImageEffects.java:525)
at com.orange.sketch.main._button_sketch_click(main.java:310)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:158)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:154)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:54)
at android.view.View.performClick(View.java:2538)
at android.view.View$PerformClick.run(View.java:9152)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)
java.lang.ArrayIndexOutOfBoundsException
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
 
Last edited:

mkvidyashankar

Active Member
Licensed User
Longtime User
I checked other effects also. it is throwing the same error in these effects

Blur
Emboss
Engrave
paintify
paintify2
posaterize
skecthify
 

mkvidyashankar

Active Member
Licensed User
Longtime User
Hi

Here is the project file
 

Attachments

  • sketch.zip
    249.9 KB · Views: 351

XverhelstX

Well-Known Member
Licensed User
Longtime User
I tried to improve the convulationmatrix, which i thought i had fixed, but apparently leaded to the arrayoutofboundexception.

I reuploaded the new Library under RSImageProcessingFixed which have the updated lib files.

Note that ImageProcessing (Sketchify, etc) does quite a lot of time on processing the images cause it uses setpixel instead of setpixels.

Tomas
 

vb1992

Well-Known Member
Licensed User
Longtime User
you might like this effect better

B4X:
Sub Activity_Create(FirstTime As Boolean)

  Activity.LoadLayout("layout1")
' If File.IsDirectory(File.DirRootExternal,"/Sketchy/") =False Then
'       File.MakeDir(File.DirRootExternal,"/sketchy/")
'  End If
'      filedire=File.DirRootExternal & "/Sketchy/" 
     
     
     panel1.SetLayout(0,0,100%x,100%y)
     button_sketch.SetLayout(50dip,100%y-40dip,100dip,40dip)
     imageview1.SetLayout(5dip,50dip,100%x-10dip,0.70*100%x)
      bitmap1.Initialize(File.DirAssets,"IMG_2436.jpg")
     ldratio = bitmap1.Width/bitmap1.Height
     
     imageview1.Bitmap = LoadBitmapSample(File.DirAssets,"IMG_2436.jpg",300,300/ldratio)
     io.Initialize
     
     End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
Sub Button_sketch_Click
    Dim bitmap2 As Bitmap
   bitmap2.Initialize3(imageview1.Bitmap)
   'bitmap2= ii.GreyScale(bitmap2)
   'bitmap2=ii.Invert(bitmap2)
'   bitmap2=ii.Invert(bitmap2)
bitmap2= ii.Brightness(bitmap2,11)
bitmap2= ii.Contrast(bitmap2,21)
   bitmap2 =ii.Sketchify(bitmap2,16,0)
   
   
    imageview1.bitmap = bitmap2
   End Sub
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…