static int Velodyne_init(Velodyne *self, PyObject *args, PyObject *kwds) { PyObject *images; char* poster_name; if (!PyArg_ParseTuple(args, "snnn", &poster_name, &(self->width), &(self->height), &(self->nb_rot))) return -1; size_t poster_size = sizeof(velodyne3DImage); STATUS s = posterCreate (poster_name, poster_size, &self->id); if (s == ERROR) { char buf[1024]; h2getErrMsg(errnoGet(), buf, sizeof(buf)); printf ("Unable to create the %s poster : %s\n",poster_name, buf); return -1; } printf("Succesfully created poster %s of size %zd\n", poster_name, poster_size); self->size = self->width * self->height; self->img.width = VELODYNE_3D_IMAGE_WIDTH; self->img.maxScanWidth = VELODYNE_3D_IMAGE_WIDTH; self->img.height = (int)(ceil)(self->size * self->nb_rot / VELODYNE_3D_IMAGE_WIDTH); self->current_rot = 0; return 0; }
int main(int argc, char *argv[]) { POSTER_ID p1, p2, p3; if (h2initGlob(0) == ERROR) { h2perror("h2initGlob"); exit(2); } if (posterCreate(TEST_POSTER_NAME, TEST_POSTER_SIZE, &p1) == ERROR){ h2perror("posterCreate"); exit(2); } if (posterFind(TEST_POSTER_NAME, &p2) == ERROR) { h2perror("posterFind"); exit(2); } if (posterDelete(p1) == ERROR) { h2perror("posterDelete"); exit(2); } if (posterFind(TEST_POSTER_NAME, &p3) == OK) { fprintf(stderr, "posterFind on a closed poster succeded!\n"); exit(3); } exit(0); }
POSTER_ID init_data (const char* poster_name, const char* reference_frame, float confidence, int* ok) { POSTER_ID id; STATUS s = posterCreate (poster_name, sizeof(POM_ME_POS), &id); if (s == ERROR) { char buf[1024]; h2getErrMsg(errnoGet(), buf, sizeof(buf)); printf ("Unable to create the %s poster : %s\n", poster_name, buf); *ok = 0; return (NULL); } printf ("INIT ID = %p (pointer)\n", id); ref_name = strdup(reference_frame); POM_ME_POS* pos = posterAddr(id); memset(pos, 0, sizeof(POM_ME_POS)); pos->kind = POM_ME_ABSOLUTE; pos->confidence = confidence; *ok = 1; return (id); }
/* * Create a poster, and fill it with information which don't change during the * execution, including bank_name, camera_name, nb_images, size of images, * camera calibration... * * Return a POSTER_ID on success, NULL otherwise * * you must call finalize when you don't use anymore the POSTER_ID */ POSTER_ID init_data (char* poster_name) { POSTER_ID id; STATUS s = posterCreate (poster_name, sizeof(SICK_CART_MEASURES_STR), &id); if (s == ERROR) { char buf[1024]; h2getErrMsg(errnoGet(), buf, sizeof(buf)); printf ("Unable to create the %s poster : %s\n",poster_name, buf); return (NULL); } return (id); }
int main(int argc, char **argv) { char *nom; int i; POSTER_ID id; if (argc == 1) { nom = "test"; } else { nom = argv[1]; } if (posterCreate(nom, sizeof(int), &id) != OK) { printf("Error posterCreate %x\n", errnoGet()); h2printErrno(errnoGet()); exit(-1); } while (1) { scanf("%d", &i); /* posterWrite(id, 0, &i, sizeof(int)); */ if (posterTake(id, POSTER_WRITE) == ERROR) { fprintf(stderr, "Error posterTake: "); h2printErrno(errnoGet()); } *(int *)posterAddr(id) = i; if (posterGive(id) == ERROR) { fprintf(stderr, "Error posterGive: "); h2printErrno(errnoGet()); } if (i == -1) { printf("Bye\n"); posterDelete(id); exit(0); } } return 0; }
static int Stereopixel_init(Stereopixel *self, PyObject *args, PyObject *kwds) { PyObject *images; char* poster_name; if (!PyArg_ParseTuple(args, "snn", &poster_name, &(self->width), &(self->height))) return -1; size_t poster_size = sizeof(Spix3DImage) + self->width * self->height * sizeof(Spix3DPixel); STATUS s = posterCreate (poster_name, poster_size, &self->id); if (s == ERROR) { char buf[1024]; h2getErrMsg(errnoGet(), buf, sizeof(buf)); printf ("Unable to create the %s poster : %s\n",poster_name, buf); return -1; } printf("Succesfully created poster %s of size %zd\n", poster_name, poster_size); Spix3DImage* img = posterAddr(self->id); posterTake(self->id, POSTER_WRITE); img->width = self->width; img->height = self->height; self->size = self->width * self->height; // dummy matrix memset(img->intrinseque_rectified, 0, sizeof(img->intrinseque_rectified)); posterGive(self->id); return 0; }
/* * Create a poster, and fill it with information that don't change during the * execution * * Return a POSTER_ID on success, NULL otherwise * * you must call finalize when you don't use anymore the POSTER_ID */ POSTER_ID init_data (char* poster_name, int* ok) { size_t poster_size = 0; POSTER_ID id; poster_size = sizeof(VimanObjectPublicArray); STATUS s = posterCreate (poster_name, poster_size, &id); if (s == ERROR) { char buf[1024]; h2getErrMsg(errnoGet(), buf, sizeof(buf)); printf ("Unable to create the %s poster : %s\n",poster_name, buf); *ok = 0; return (NULL); } //printf("Poster '%s' created of type VIMAN (size %zd)\n", poster_name, poster_size); //printf ("INIT ID = %p (pointer)\n", id); *ok = 1; return (id); }
int main(int argc, char *argv[]) { POSTER_ID posterIdC; POSTER_ID posterIdF; TESTPOST_STR testIn = INIT_TESTPOST_STR; TESTPOST_STR testOut; int size = sizeof(TESTPOST_STR); int sizeOut; H2_ENDIANNESS endianness; char c; char msg[256]; printf ("testPosterWrite: LOCAL ENDIANNESS = %d\n", h2localEndianness()); /* create */ if (posterCreate(TEST_POSTER_NAME, size, &posterIdC) == ERROR) { printf ("testPosterWrite: posterCreate(%s) failed : %s\n", TEST_POSTER_NAME, h2getErrMsg(errnoGet(), msg, 256)); return 1; } printf ("testPosterWrite: poster %s created. Id = %0x\n", TEST_POSTER_NAME, (int)posterIdC); posterEndianness(posterIdC, &endianness); printf ("testPosterWrite: posterEndianness(%s) = %d\n\n", TEST_POSTER_NAME, endianness); /* write */ if ((sizeOut=posterWrite(posterIdC, 0, (void *)&testIn, size)) != size) { printf ("testPosterWrite: posterWrite size = %d != %d \n", sizeOut, size); return testEnd(posterIdC); } printf ("testPosterWrite: poster %s writen\n", TEST_POSTER_NAME); /* read after create */ if ((sizeOut=posterRead(posterIdC, 0, (void *)&testOut, size)) != size) { printf ("testPosterWrite: posterRead size = %d != %d \n", sizeOut, size); return testEnd(posterIdC); } printf ("testPosterWrite: poster %s read OK\n", TEST_POSTER_NAME); /* display */ if (endianness != h2localEndianness()) endianswap_TESTPOST_STR(&testOut); printTestStr("Write", &testOut); printf ("\n"); /* find */ if (posterFind(TEST_POSTER_NAME, &posterIdF) == ERROR) { printf ("testPosterWrite: posterFind failed\n"); return testEnd(posterIdC); } /* printf ("posterFind TEST_POSTER_NAME posterIdF = %d\n", (int)posterIdF); */ posterEndianness(posterIdF, &endianness); printf (" endianness = %d\n", endianness); /* read after find */ if ((sizeOut=posterRead(posterIdF, 0, (void *)&testOut, size)) != size) { printf ("testPosterWrite: posterRead size = %d != %d \n", sizeOut, size); return testEnd(posterIdC); } /* display */ if (endianness != h2localEndianness()) endianswap_TESTPOST_STR(&testOut); printTestStr("Write", &testOut); /* find again */ if (posterFind(TEST_POSTER_NAME, &posterIdF) == ERROR) { printf ("testPosterWrite: posterFind failed\n"); return testEnd(posterIdC); } printf ("PosterIdF %s = %d\n", TEST_POSTER_NAME, (int)posterIdF); posterEndianness(posterIdF, &endianness); printf (" endianness = %d\n", endianness); printf ("Return to end ...."); fflush(stdout); scanf("%c", &c); /* end */ return testEnd(posterIdF); }