02-08-2007 03:10 PM
02-08-2007 05:10 PM
02-09-2007 01:50 AM
@Bala L wrote:
It looks like the problem is because of the file operations I perform
to read/write the image. When I remove the file ops in the file-write
function, labVIEW no longer crashes. Also, it looks like file-read is
not loading the image from the file to the memory.
Do I have to change settings somewhere to handle file ops while using
CIN? I did add the CINProperties() function to the CIN code to make
labVIEW recognize my code as being thread-safe. But that hasn't
changed anything.
02-09-2007 08:40 AM
02-09-2007 11:40 AM
02-09-2007 02:10 PM
@Bala L wrote:
> I allocate memory for the arrays dynamically in the C++ code to hold
> the image. After my calculations, I assign the desired values to the
> function's return variables before releasing the array memory. I am
> pretty certain that the C++ code works correctly since I didn't have
> any memory leaks or weird behaviour when I ran my C++ code in the .NET
> IDE.
>
> A question about reentrancy - does reentrance mean that the CIN
> function is called repeatedly by more than one functions? Or is my
> code reentrant even if other parts of the code are multi-threaded?
02-13-2007 09:10 AM
02-13-2007 09:36 AM - edited 02-13-2007 09:36 AM
As I thought! t_i and T_j are references to integers, but you just assign them with 0 or the cranial and torso integers. Maybe this code would work in a pure C++ program, I'm not sure, but in C it is important to assign the variables correctly.
@Bala L wrote:
"It could be something simple as aforgotten * dereferencing and most
probably when you do source level deugging youwill see it at some
point and hit yourself for not having noticed earlier."
--I figured out why the file wasn't being read properly - I wasn't
assigning enough memory for the file.
I am still having the issue of Labview closing down during a file-
write operation. This is the structure of the C++ code:
// file1.cpp
MgErr CINRun(LVBoolean *start, int32 *t_i, int32 *t_j)
{
/* Insert code here */
func1(start, t_i, t_j);
return noErr;
}
// file2.cpp
void func1(LVBoolean *start, int32 *t_i, int32 *t_j)
{
if(*start == true)
{
CImg img(ROW, COL, FRAMES); // Image object
int torso, cranial;
img.fileRead(INPUT_FILENAME); // Works fine
img.fileWrite(OUTPUT_FILENAME); // Works fine
img.detectShape(torso, cranial);
t_i = torso;
t_j = cranial;
}
else
{
t_i = 0;
t_j = 0;
}
}
The call to detectShape() does all the calculations correctly. At
the end of this function, when I write out an image file with the
detected results, it causes Labview to close down. I tried debugging
the code in the .NET IDE through Labview using the online reference
("using external code in labview" pdf document). The file isn't being
opened correctly, and it is causing the program to exit. The first
fileWrite() is working fine. I'm trying to figure out why this is
happening.
Message Edited by rolfk on 02-13-2007 04:38 PM
02-13-2007 11:10 AM