LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why column data of a database table is not getting updated in each iteration?

Hello All!

I am trying to uodate my database table which is structured as:

Column0: Number of Frames in a AVI (Total 868 Frames in my AVI)

Column1: Blob1, Column2: Blob2, Column3: Blob3 i.e particles/blobs present in a AVI

Each cell of table: represents a set of (X,Y) coordinates of all the pixels available in a particular frame. 

I have successfully inserted  frame number  and pixel coordinates of blob1 values in Column0 and Column1 respectively.

Next, I want to update column2 i.e Blob2 with it's corresponding pixel coordinates for each  frame of AVI. I have done this inside a FOR Loop so that it gets updated for each  frame.

Instead of updating each row of Column2 i.e Blob2 with the corresponding frames , I am getting an output where only the values (pixel coordinates) of the last frame is updated in all the rows of Column2. This means in all the rows of Column2, I am getting the same pixel values in all the rows of Column2 instead of different values in each row.

Can someone help me out what is my mistake or any Information?

 

 

Download All
0 Kudos
Message 1 of 14
(3,289 Views)

Why are you now changing your database INSERT to a database UPDATE?  An UPDATE will change every entry in the database that matches your criteria (Where frame < 868).  So when your for loop finishes execution, every entry in your dB that has a frame number less than 868 will have the same particle coordinates as the last entry in your particle array.  I posted the insert code in one of the other posts that showed how to insert all 3 particles.  Every time I see your code, you have basically rewritten it to do something entirely different.  One step forward and two steps back.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 2 of 14
(3,264 Views)

I am using update because i created my table first by inserting values in first 2 columns i.e Frame (Column 0) and Blob1 (Column 1) . Okay. Thanks for the information about UPDATE.  I was not aware before. Yes, I have seen your insert code and it is really helpful. But, my problem is that I have 3 different color particles/blob to which I have to enter the color threshold individually. So, I have to insert the coordinates values of each blob/particle separately in each VI run. I couldn't find a way how to enter the color threshold for all the 3 particles together, so I am inserting the values in each particle column separately. 

Do you know any way where I can send the coordinates values of each blob to its respective columns separately?

0 Kudos
Message 3 of 14
(3,258 Views)

I'm a bit confused now.  Your code for generating the 3D array has a loop for N: number of frames, N: number of particles and then another nested for loop for the X,Y coordinates of the particles.  The code in this post shows extracting the 3 different particles and inserting them into an array with the frame number.  Is this something different than the color threshold that you are talking about?

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 4 of 14
(3,250 Views)

yes, it is the same code. If you check my code, IMAQ Color Threshold is inside the FOR Loop for N: number of frames. I can't give the Color threshold for all the 3 different Color blobs together (each blob has different color threshold values). Therefore, I am giving the Color threshold to each blob separately in each VI run. That is why I am inserting the coordinates of each blob separately in different columns. Also, I want to insert all the rows of Blob2 column till the Frame <868 (total no of frames is 0-867) with its respective coordinates of a particular Frame 

I would be grateful if you could share any idea how I can execute my desired goal? 

0 Kudos
Message 5 of 14
(3,231 Views)

Okay. So, I have replaced UPDATE with INSERT VI and it insert the coordinates in column Blob2. But only Problem is: Instead of inserting from row 0 / Frame 0, the column2 values are inserted after the last frame i.e 867. I am not sure how to synchronize the column values with row numbers.

0 Kudos
Message 6 of 14
(3,227 Views)

So, I analyze my problem and i am in a roadblobk now with the following problems:

1. INSERT:allows me to insert the 'set of coordinates' values into a column in a  table. But,the problem with directly INSERT VI/ any parametrized query INSERT INTO Statement is that it insert values into new rows. In my case, I want to insert values from my existing row/record number 0 and not from a new row/record.

2. UPDATE: it allows me to update values in a column with existing rows but it stores only the last entry value. In my case, I want to store the 'set of coordinates' of all the frames of a 'frame array' and not the last value in the frame array.

3. INSERT ALL THE 3 BLOBS AS A CLUSTER: This is the best possible solution for my case. But, I can't do the Color threshold for all the 3 blobs simultaneously in order to find the 'pixel coordinates' of blobs. This is becuase I can only give a color threshold to each blob separately in my pre processing phase (each blob have different Colors and hence different Color threshold). Otherwise, the blobs won't be detected by the VI and then no coordinates for blobs. Therefore, it is not possible to run all the 3 blobs together and store their coordinates simultaneously. 

 

So, is there a way where I can insert pixel values to my Blob2/Column2 and Blob3/Column3 from the 0th row  (already created with Columns-Frame and Blob1) and not from a new row ?

0 Kudos
Message 7 of 14
(3,210 Views)

You're going to want to do this all in one run of the VI.  If you are inserting values into the db on the first run of the VI and then updating values during the second and third run, it's going to be a hassle and not intuitive to a user. 

You need to find a way to define all 3 color thresholds at the beginning.  One way is to put the RGB selectors into a cluster and add them to an array.   

thresholds.PNG

Now when you search for the particles and get the coordinates, you can do that inside a for loop and auto-index the color threshold values.  So for each frame, you are going to have a for loop that looks for the first particle with the first color threshold value, get it's coordinates and add it to an autoindexed output.  Repeat for the next particle with the next color threshold value.  and again for the third.  Now repeat all of this again for frame 2, frame 3, etc.  

 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 8 of 14
(3,207 Views)

@aputman wrote:

You're going to want to do this all in one run of the VI.  If you are inserting values into the db on the first run of the VI and then updating values during the second and third run, it's going to be a hassle and not intuitive to a user. 

You need to find a way to define all 3 color thresholds at the beginning.  One way is to put the RGB selectors into a cluster and add them to an array.   

thresholds.PNG

Now when you search for the particles and get the coordinates, you can do that inside a for loop and auto-index the color threshold values.  So for each frame, you are going to have a for loop that looks for the first particle with the first color threshold value, get it's coordinates and add it to an autoindexed output.  Repeat for the next particle with the next color threshold value.  and again for the third.  Now repeat all of this again for frame 2, frame 3, etc.  

 


Okay you are right. Thanks. But,I am not understanding which new for Loop you are telling to add. Can you Show me which part of VI or a small Code of what you meant? Thanks in advance.

0 Kudos
Message 9 of 14
(3,203 Views)

Is my attached VI what you meant? 

Download All
0 Kudos
Message 10 of 14
(3,192 Views)