本文整理汇总了C++中ofImage::isAllocated方法的典型用法代码示例。如果您正苦于以下问题:C++ ofImage::isAllocated方法的具体用法?C++ ofImage::isAllocated怎么用?C++ ofImage::isAllocated使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofImage
的用法示例。
在下文中一共展示了ofImage::isAllocated方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createPayloadRasterBody
//
// TODO([email protected]): finish implementation
//
ofBuffer ofxEpilog::createPayloadRasterBody(ofImage raster_img, OutputConfig &out_conf)
{
ofLog(OF_LOG_WARNING) << "bool ofxEpilog::createPayloadRasterBody(ofImage raster_img, OutputConfig &out_conf) is not implemented yet.";
// payload buffer
ofBuffer buffer;
// add raster image part
if(raster_img.isAllocated())
{
//
// convert to PCL raster format from ofImage
//
}
return buffer;
}
示例2: ofMap
void ofxDepthImageCompressor::convertTo8BitImage(unsigned short* buf, ofImage& image){
int nearPlane = 500;
int farPlane = 7000;
if(!image.isAllocated()){
image.allocate(640,480,OF_IMAGE_GRAYSCALE);
}
unsigned char* pix = image.getPixels();
int stride = image.getPixelsRef().getNumChannels();
for(int i = 0; i < 640*480; i++){
//ofMap(buf[i], nearPlane, farPlane, 255, 0, true);
unsigned char value = buf[i] == 0 ? 0 : 255 - (255 * (buf[i] - nearPlane) ) / farPlane;// + ofMap(buf[i], nearPlane, farPlane, 255, 0, true);
for(int c = 0; c < stride; c++){
pix[i*stride+c] = value;
}
}
image.update();
}
示例3: createPayloadCombinedBody
ofBuffer ofxEpilog::createPayloadCombinedBody(ofImage raster_img, ofPolyline vector_vertexes)
{
if(!raster_img.isAllocated())
return;
if(vector_vertexes.size() == 0)
return;
ofBuffer buffer;
buffer.append(createPayloadRasterBody(raster_img, getOutputConfig()));
// end raster part regardless of it's empty
buffer.append(PCL_RASTER_END);
// begin HPGL commands (vector part)
buffer.append(HPGL_START);
buffer.append(HPGL_VECTOR_INIT + HPGL_CMD_DELIMITER);
buffer.append(createPayloadVectorBody(vector_vertexes, getOutputConfig()));
return buffer;
}
示例4: send
bool ofxEpilog::send(ofImage img, int w_mm, int h_mm)
{
//
// TODO([email protected]): finish implementation
//
if(!img.isAllocated())
return false;
if(w_mm <= 0 || h_mm <= 0)
return false;
ofLog(OF_LOG_WARNING) << "bool ofxEpilog::send(ofImage img, int w_mm, int h_mm) is not implemented yet.";
return false;
//
// dummy implementation
//
ofBuffer buffer;
buffer.append(createPayloadHeader(getMachineProfile(), getOutputConfig()));
// create raster part
buffer.append(createPayloadRasterBody(img, getOutputConfig()));
// end raster part regardless of it's empty
buffer.append(PCL_RASTER_END);
// begin HPGL commands (vector part)
buffer.append(HPGL_START);
buffer.append(HPGL_VECTOR_INIT + HPGL_CMD_DELIMITER);
if(!keep_alive)
buffer.append(createPayloadFooter()); // end the session
if(pjl_file.get() != NULL)
pjl_file->writeFromBuffer(buffer);
return tcp_client.sendRaw(buffer);
}
示例5: draw
//--------------------------------------------------------------
void testApp::draw()
{
if (image.isAllocated())
image.draw(0, 0);
}
示例6: update
void update() {
#ifdef INSTALL
if(cam.update()) {
ofPixels& pixels = cam.getColorPixels();
#else
cam.update();
if(cam.isFrameNew()) {
ofPixels& pixels = cam.getPixelsRef();
#endif
// next two could be replaced with one line
ofxCv::rotate90(pixels, rotated, rotate ? 270 : 0);
ofxCv:flip(rotated, rotated, 1);
Mat rotatedMat = toCv(rotated);
if(tracker.update(rotatedMat)) {
ofVec2f position = tracker.getPosition();
vector<FaceTrackerData*> neighbors = data.getNeighborsCount(position, neighborCount);
FaceTrackerData curData;
curData.load(tracker);
if(!neighbors.empty()) {
nearestData = *faceCompare.nearest(curData, neighbors);
if(nearestData.label != lastLabel) {
similar.loadImage(nearestData.getImageFilename());
#ifdef INSTALL
whitePoint = getWhitePoint(similar);
#else
whitePoint.set(1, 1, 1);
#endif
}
lastLabel = nearestData.label;
}
if(faceCompare.different(curData, currentData) && faceCompare.different(curData, neighbors)) {
saveFace(curData, rotated);
currentData.push_back(pair<ofVec2f, FaceTrackerData>(position, curData));
}
}
presence.update(tracker.getFound());
if(presence.wasTriggered()) {
presenceFade.stop();
}
if(presence.wasUntriggered()) {
for(int i = 0; i < currentData.size(); i++) {
data.add(currentData[i].first, currentData[i].second);
}
currentData.clear();
presenceFade.start();
}
}
}
void draw() {
ofBackground(255);
CGDisplayHideCursor(NULL);
ofSetColor(255);
if(similar.isAllocated()) {
shader.begin();
shader.setUniformTexture("tex", similar, 0);
shader.setUniform3fv("whitePoint", (float*) &whitePoint);
similar.draw(0, 0);
shader.end();
}
ofPushStyle();
if(presenceFade.getActive()) {
ofSetColor(0, ofMap(presenceFade.get(), 0, 1, 0, 128));
ofFill();
ofRect(0, 0, ofGetWidth(), ofGetHeight());
ofSetColor(255, ofMap(presenceFade.get(), 0, 1, 0, 32));
data.drawBins();
ofSetColor(255, ofMap(presenceFade.get(), 0, 1, 0, 64));
data.drawData();
}
ofSetColor(255, 64);
ofNoFill();
if(!tracker.getFound()) {
ofCircle(tracker.getPosition(), 10);
}
tracker.draw();
ofPopStyle();
#ifndef INSTALL
drawFramerate();
#endif
}