Ask Your Question
-1

I'am done my JAVAFX application with opencv,but processing is running slowly?

asked 2020-02-14 11:33:58 -0500

Hello! I have a javafx application and I am using opencv lib. But I have a big problem, my application processing is running slowly.I do operations with pixel values ​​of the pictures By the way, I use 4 nested for loops( for 672 images).There are also multiple functions in loops. I removed all the unnecessary details and made the code the simplest. But it takes more than 1 hour to work!!

Thank you for your interests

edit retag flag offensive close merge delete

Comments

But it takes more than 1 hour to work!!

heh

berak gravatar imageberak ( 2020-02-14 14:21:19 -0500 )edit

Yes, it took more than 1 hour to work. Why off-topic???

Yasemin gravatar imageYasemin ( 2020-02-14 14:23:44 -0500 )edit

Nobody can help you if you don't 1l tell what you do to the images, 2l show an example image and tell the generic properties of the images (size..) 3) show your code and 4) describe the running environment - a low memory system could spend its time swapping.

Note that you should be able to find out where exactly the time is spent. Java has functions for that.

mvuori gravatar imagemvuori ( 2020-02-14 14:26:02 -0500 )edit

it took more than 1 hour to work

doing what, btw ?

where's the problem ?

berak gravatar imageberak ( 2020-02-14 14:28:39 -0500 )edit

my question is not off-topic or something, it is a very opencv related situation. javafx can be a special detail. You might think as java, I didn't think it would be hard. As for the details, I access the pixel values ​​in the operations I do in the loops, and perform operations such as searching and changing depending on some conditions. the program runs very slowly in these for loops. In summary, the processes I deal with pixel values ​​are huge. my pixel values ​​are 16 bits

Yasemin gravatar imageYasemin ( 2020-02-14 14:41:19 -0500 )edit

there are 4 more functions like this, in the loops.

Yasemin gravatar imageYasemin ( 2020-02-14 14:49:55 -0500 )edit

please:

  • edit your question, and put (the relevant part of) your code there (not into comments).
  • try to explain, what you try to achieve, and what it should do.

then we can try to help you using opencv's api better (NEVER write loops like that !)

berak gravatar imageberak ( 2020-02-15 03:32:29 -0500 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2020-02-16 13:48:03 -0500

updated 2020-02-16 14:38:42 -0500

LBerger gravatar image

Okey I understand, thank you:) I have to use nested 4 *for loops and my code part;

for(int i =lowpoint;i<(highpoint-1);i++) 
{

for(int j = i+1;i<highpoint;j++)
{

   for(int k = offpoint;k<highpoint;k++)
{

       result1=function1(i,j,image);
       result2=function2(image1,image2,integernumber);

       for(int m=impoint;m<highpoint;m++){
          result2=function3(image, ver-size,hor_size,,result1[0],result1[1],m);
          result3=function4(result2,duoblenumber);
          sum = sum+result3[m];
          }
       }
       sum=sum/doublenumber2;
     }
}

all functions include operations related to the pixel values of the images except function2.

pixel values operations, for example;

**public  Mat [] Function(Mat[] imagearray, int ver_size, int hor_size, double doublenumber, int lowpoint, int highpoint, int offset_point){
    public static double[] colorspace1;
    public static double[] colorspace2;
    public static double[] colorspace3;
float [] colorspace_u=new float[1];
for(int i=0;i<ver_size;i++){
            for (int j=0;j<hor_size;j++){
                colorspace1=imagearray[high_temp_point].get(i,j);
                colorspace2=imagearray[low_temp__point].get(i,j);
                colorspace_u[0]=division/(float)(colorspace2[highpoint]-colorspace1[lowpoint]);
                if (colorspace_u[0]>5){
                    colorspace_u[0]=5;
                }
                else if(colorspace_u[0]<0.2){
                    colorspace_u[0]=(float)0.2;
                }
                image3.put(i,j,colorspace_u[0]);
               colorspace3=imagearray[offset_point].get(i,j);
                colorspace_u[0]=doublenumber-(float)(colorspace3[0]*(double)colorspace_u[0]);
                image4.put(i,j,(float)colorspace_u[0]);
            }
        }
        result[0]=image3;
        result[1]=image4;
       return result;
}**

//So other function's calculate like this.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-02-14 11:33:58 -0500

Seen: 17 times

Last updated: 3 hours ago