我使用Synthetic Aperture Radar卫星的非常大的数据集.这些可以被认为是一侧10k像素量级的高动态范围灰度图像.
最近,我一直在开发Lindeberg尺度空间脊检测算法的单尺度变体的应用,用于检测SAR图像中的线性特征.这是对使用方向滤波器或使用Hough变换的改进,这两种方法以前都使用过,因为它的计算成本低于其中任何一种.(我将在4月份的JURSE 2011上展示一些最新成果,如果有帮助,我可以上传预印本).
我目前使用的代码生成一个记录数组,每个像素一个,每个记录描述矩形到像素右下角的一个脊段,并由相邻的像素限定.
struct ridge_t { unsigned char top, left, bottom, right };
int rows, cols;
struct ridge_t *ridges; /* An array of rows*cols ridge entries */
Run Code Online (Sandbox Code Playgroud)
在一个条目ridges包含脊段如果正好有两个的top,left,right并bottom具有范围值0 - 128.假设我有:
ridge_t entry;
entry.top = 25; entry.left = 255; entry.bottom = 255; entry.right = 76;
Run Code Online (Sandbox Code Playgroud)
然后我可以找到脊段的开始(x1,y1)和结束(x2,y2):
float x1, y1, x2, y2;
x1 = (float) col + (float) entry.top / 128.0;
y1 = (float) …Run Code Online (Sandbox Code Playgroud) c scalability image-processing feature-detection satellite-image
有人可以向我解释下面的问题是什么,更重要的是为什么?
int main( int argc, char *argv[] )
{
char array[] = "array";
char **test;
test = &array;
*test[0] = 'Z';
printf( "%s\n", array );
return 0;
}
Run Code Online (Sandbox Code Playgroud)
编辑
我上面的例子基于这样一个崩溃的函数:
void apple( char **pp )
{
*pp = malloc( 123 );
*pp[0] = 'a'; // technically this is correct but in bad form
*pp[1] = 'b'; // incorrect but no crash
*pp[2] = '\0'; // incorrect and crash
}
Run Code Online (Sandbox Code Playgroud)
正如Vaughn Cato向我指出的那样虽然*pp[0] = 'a';没有崩溃,但它的状态还不好.正确的形式是括号
void apple( char **pp ) …Run Code Online (Sandbox Code Playgroud) 我正在尝试编译这个程序,如第19页的Beej网络编程指南中所述.
#include <stdio.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
int main() {
int status;
struct addrinfo hints;
struct addrinfo *servinfo; /* Will point to the results */
memset(&hints, 0, sizeof hints); /* Make sure the struct is empty */
hints.ai_family = AF_UNSPEC; /* Don't care IPv4 or IPv6 */
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;
if ((status = getaddrinfo(NULL, "3490", &hints, &servinfo)) != 0) {
fprintf(stderr, "getaddrinfo error: %s\n", gai_strerror(status));
exit(1);
}
/* Servinfo now points to a …Run Code Online (Sandbox Code Playgroud) 我又来了.在挖掘一些C源代码时,我发现了代码片段
char **words
Run Code Online (Sandbox Code Playgroud)
我知道变量名称之前的单个星号"指向"指针,但这两个星号的目的是什么?
我应该覆盖CtrlC信号并用它来打印信息.它不应该结束该计划.
到目前为止发生的事情是,当CtrlC按下它时会打印消息,但结束程序.
当我问我的教授他告诉我这样做时:你需要让信号处理程序不要继续处理信号.现在,信号由您的代码处理,然后转到父处理程序.
有没有我应该添加的方法或者我需要在某个地方移动信号安装程序?
到目前为止这是我的代码:
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <signal.h>
#include "Input.h"
#include "CircleBuff.h"
//void handler_function(int signal_id);
void catch_int(int sig_num){
//reset the signal handler again to catch_int, for next time
signal(SIGINT, catch_int);
//print message
printf("Print History");
fflush(stdout);
}
void printHistory(CircleBuff hist){
cout << "Complete History:\n" << endl;
hist.print();
cout << endl;
}
int main(int argc, char** argv){
struct sigaction signal_action; /* define table */
signal_action.sa_handler = catch_int; /* insert …Run Code Online (Sandbox Code Playgroud) 基于Python的单元测试像"鼻子"这样的框架有很多丰富的功能,我想知道我们是否可以利用它们来测试C代码.
我们在解释老师方面遇到了很多麻烦.我们要求澄清并从他那里得到以下回复
对于execve,使用导出的变量向它发送一个环境,并创建一个内置命令来生成/ bin/bash的子shell,这样就可以使用env查看导出的变量.
(他在谈论在这里创建我们自己的环境变量.)
这与我在Stack Overflow上的以下帖子有关(阅读这篇文章将帮助您理解我想要做的事情):
我们对此非常困惑.我将再次解释我们现在要做的事情.与你的Linux shell如何做到这一点,我们需要编写自己的程序,可以设置环境变量,如PATH和USER以及用户想要定义的其他任何变量.
你将如何调用它的一个例子是(在你的程序中提示):
mysetenv dog spike
Run Code Online (Sandbox Code Playgroud)
这将创建一个看起来像"dog = spike"的环境变量
更重要的是,我们需要能够设置自己的PATH变量并将其发送到exec命令.这是一个令人困惑的部分,因为基于我们所有的问题,我们不明白我们应该做什么.
这个问题几乎说明了一切.
我不知道该如何做到这一点,并没有任何有用的东西.
这是一些示例函数:
add(int x, int y) {
return x+y;
}
Run Code Online (Sandbox Code Playgroud)
和,
mean(int x1, int y1, int x2, int y2) {
return (x1 + y1 + x2 + y2) / 4;
}
Run Code Online (Sandbox Code Playgroud)
到目前为止,我已尝试将typedef与两者一起使用,但我无法弄清楚如何使某些东西指向其中一种类型:
typedef int (*mathfunc2)(int x, int y);
typedef int (*mathfunc4)(int x1, int y1, int x2, int y2);
????? func_table[2] = {add, mean};
Run Code Online (Sandbox Code Playgroud) 我尝试在Linux中控制鼠标.Xlib似乎有效,但是当我尝试将它与OpenCV一起使用时,它会一直返回:
Resource temporarily unavailable
Run Code Online (Sandbox Code Playgroud)
所以我决定写"/ dev/psaux".代码如下:
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main() {
unsigned char a[5]={0, 0xff, 0, 0x28, 0xff};
int fp = open ("/dev/psaux", O_WRONLY);
if(!fp)printf("open error:%s\n", strerror(errno));
for(int i = 0; i < 10; i++)
printf("write:%d\t\t%s\n", write(fp, a, 5), strerror(errno));
close(fp);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
编译它:
gcc my_psaux.c -o my_psaux -std=gnu99 -g
Run Code Online (Sandbox Code Playgroud)
跑,得到
$sudo ./my_psaux
write:5 Success
write:5 Success
write:5 Success
write:5 Success
write:5 Success
write:5 Success
write:5 Success …Run Code Online (Sandbox Code Playgroud) 当我试图执行我的程序时它得到的错误是这样的 -
sendip: malloc.c:4631: _int_malloc: Assertion `(unsigned long)(size)
>= (unsigned long)(nb)' failed
Run Code Online (Sandbox Code Playgroud)
通过valgrind尝试捕获错误,得到了这个 -
HEAP SUMMARY:
==3335== in use at exit: 24 bytes in 2 blocks
==3335== total heap usage: 111 allocs, 109 frees, 7,929 bytes allocated
==3335==
==3335== 4 bytes in 1 blocks are definitely lost in loss record 1 of 2
==3335== at 0x40268A4: malloc (vg_replace_malloc.c:236)
==3335== by 0x8049EEF: main (sendip.c:435)
==3335==
==3335== 20 bytes in 1 blocks are definitely lost in loss record 2 of 2
==3335== …Run Code Online (Sandbox Code Playgroud) c ×10
linux ×2
arrays ×1
c++ ×1
exec ×1
execve ×1
input ×1
linker ×1
malloc ×1
memory-leaks ×1
mouse ×1
networking ×1
path ×1
pointers ×1
python ×1
scalability ×1
signals ×1
unit-testing ×1